Login | |
|
 |
RE: adding users in AD - 12/5/2006 8:12:18 AM
|
|
 |
|
| |
ugge
Posts: 2
Score: 0
Joined: 12/5/2006
Status: offline
|
Thank you for the reply :) I did find this nice script on the web, but now im not quite sure how i can modify it to reach my needs like I wrote in my first post. Const ADS_PROPERTY_APPEND = 3 set WshShell = WScript.CreateObject("WScript.Shell") Set FSO = CreateObject("Scripting.FileSystemObject") Set NamesFile = FSO.OpenTextFile("names.csv", 1) fullname = "a" do until namesfile.AtEndOfStream Temp = NamesFile.ReadLine NamesList = Nameslist & ", " & temp if temp <> "" then Seperator = instr(Temp, ",") + 1 Seperator2 = instr((seperator), temp, ",") - 1 FirstName = left(Temp, Seperator - 2) LastName = Mid(Temp, Seperator, Seperator2 - Seperator + 1) userName = Left(firstname,1) & lastname FullName = FirstName & " " & LastName Set objOU = GetObject("LDAP://ou=Production,dc=DomainName,dc=local") 'create user account Set objUser = objOU.Create("user", "cn=" & fullname) objUser.Put "sAMAccountName", username objuser.sn = LastName objuser.givenname = FirstName objuser.physicalDeliveryOfficeName = "MD" objuser.displayname = FirstName & " " & LastName objuser.userPrincipalName = UserName & "@DomainName.local" objuser.Description = "Contact Center Representative" objuser.SetInfo 'stuff that has to be set after account created objuser.ChangePassword "", "password" objuser.AccountDisabled = FALSE objUser.Put "pwdLastSet", 0 objuser.SetInfo 'put in groups Set objGroup = GetObject _ ("LDAP://cn=MD_Contact Center,dc=DomainName,dc=local") objGroup.PutEx ADS_PROPERTY_APPEND, _ "member", Array("cn=" & fullname & ",ou=Production, dc=DomainName, dc=local") objGroup.SetInfo Set objGroup = GetObject _ ("LDAP://cn=MD_Contact Center Printers,dc=DomainName,dc=local") objGroup.PutEx ADS_PROPERTY_APPEND, _ "member", Array("cn=" & fullname & ",ou=Production, dc=DomainName, dc=local") objGroup.SetInfo end if loop NamesFile.close msgbox("The Following Users have been Set up" & nameslist)
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|