Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


adding users in AD

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,40389
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> adding users in AD
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 adding users in AD - 12/5/2006 4:04:13 AM   
  ugge

 

Posts: 2
Score: 0
Joined: 12/5/2006
Status: offline
Hope im correct now

I’m looking for a vbs script that does the following

I use windows 2003 and no I want to add some users to my active directory
I have a text file with around 40 names in this format peter;andersson, I understand that I have to rename that file to a csv file?

I have been looking around on the net and found some nice examples but not really what I am after, I want the script to do the following.

When the user is created, he or she get a user name in this format, peter;andersson get anpe john smith get smjo and so on

I give in the password for each person in the textfile but they have to change it at first login.

I can put in the script what group they belong to. In this stage all belong to the same group but I want be able to simply change when needed, if I add new users later.

I want the created users to show up in a text file so I can see if it was successful.

Hope someone have seen a script like that =)

Thank you for any help
 
 
Post #: 1
 
 RE: adding users in AD - 12/5/2006 7:17:12 AM   
  CaffeineAddiction

 

Posts: 144
Score: 0
Joined: 2/9/2005
From:
Status: offline
easiest way to do this that I know of is to get dsadd.exe which is part of DS tools (I belive it to be a windows power tool ... should be a free download). After that, all you would need to do is make a script to read your file and parce it as such that you could run the dsadd with proper syntax to create the users in AD

Yes, you can do this LDAP ... but for a new scripted I think scripting the dsadd tool would be a whole lot easier

_____________________________

Thanks for Answering my Questions ... I hope my Answer to your questions help!

(in reply to ugge)
 
 
Post #: 2
 
 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)



(in reply to CaffeineAddiction)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> adding users in AD Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts