Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to ADD user to Group From CSV file

Status
Not open for further replies.

dkel22

Programmer
Mar 31, 2004
49
US
I am trying to run a script during our user provisioning process to add users to a group based on selected criteria. Here's a code snippet below. I cannot sort out how to actually add the user to the group as the foundobject.ismember appartently doesn't work

While Not rs.EOF
'Do nothing but iterate since they are already in AD.
Set FoundObject = GetObject (rs.Fields(0).Value)
'Found in AD
If Instr(FoundObject.DistinguishedName,"Terminated Employees") = 1 Then
rs.MoveNext
End If
rs.MoveNext
userChanged = False
If IsNull(FoundObject) Then
Else
If (Left(DepartmentValue,3) = "251") Then
Set objGroup = GetObject("LDAP://CN=GROUP1,OU=Groups,OU=LOCATION,DC=XYZ,DC=com")
'check to see if user member of GROUP1
If (FoundObject.IsMember("LDAP://CN=GROUP1,OU=Groups,OU=LOCATION,DC=XYZ,DC=com") = FALSE) Then
'Add User to Heartland Schools Solutions DL
objGroup.Add(FoundObject)
userChanged = True

End If
End If
End If
Set FoundObject = Nothing
Wend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top