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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on Adding users to group via DSAdd and VBScript. 1

Status
Not open for further replies.

windowsfan

IS-IT--Management
Jan 26, 2007
237
US
I want to add a user to multiple groups via dsadd I tried the below script and it will work fine if I add user to one group, will not work when I try to add it to multiple groups, may be I missing something. I used both comma and semicolon between two groups but it will still not work. what I am doing wrong?

-memberof "cn=BH Residents,ou=Existing Groups,ou=BH Application Groups,dc=zhc,dc=botsford,dc=org","cn=3 North,ou=Existing Groups,ou=BH Application Groups,dc=zhc,dc=botsford,dc=org"

Same question on how to add user to multiple groups via VBScript.
strMemberOf=strMemberOf=Trim(objExcel.Cells(intRow, 18).Value)
objUser.memberOf=strMemberOf

value in cell 18 in excel is :
CN=BH Externs,OU=Existing Groups,OU=BH Application Groups,DC=zhc,DC=botsford,DC=org;CN=BH Externs1,OU=Existing Groups,OU=BH Application Groups,DC=zhc,DC=botsford,DC=org
 
it's working fine. I tried number 1 and 2 from the previous post. I came across one more thing, how to handle blank cells? for example what if Middle Initial is blank in excel, I tried the below code but did not work.
if strMI=chr(32) then strMI="" or strMI=cell from excel.
 
also is possible to use strSAM instead of strCN in bleow code.
Set objUser = objContainer.Create("User", "cn=" & strCN)
Set objUser = GetObject("LDAP://CN=" & strCN &",ou=NewUsers,dc=zhc,dc=botsford,dc=org")
 
Code:
If Len(strMI) > 0 Then
   objUser.initials=strMI
End If

also is possible to use strSAM instead of strCN in bleow code.
Yes

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
I get object already exist error for some of the users already with same name on AD. what's the best way to handle this?
what's happening is lets say if the user which is already in AD and is on row 3 in excel, I will only be able to add two user and it will fail at row 3.
Can I use on error resume next or is there some other way to handle?
 
Use on error resume next.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top