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

Creating users with script by copying existing users profile.

Status
Not open for further replies.

Bhavin78

IS-IT--Management
Oct 26, 2004
320
I work for hospitals and we have to create 100 of users every month. As of right now I use existing user profile to create new user.

I can use csvde to create new user but how can I create users based on existing profile or other smart way.
 
Here is a code snippet I found. I have the same issue but haven't had a chance to expand on this yet.

Code:
' This code copies the attributes in the Attrs array from an 
' existing object to a new one.
' ------ SCRIPT CONFIGURATION ------
arrAttrs        = Array("department","co","title","l", "c", "st")
strParentDN     = "<ParentContainer>"   ' e.g. cn=Users,dc=rallencorp,dc=com
strTemplateUser = "<TemplateUserName>"  ' e.g. template-user-sales
strNewUser      = "<NewUserName>"       ' e.g. jdoe
strPassword     = "<Password>"
' ------ END CONFIGURATION ---------
     
Const ADS_UF_NORMAL_ACCOUNT = 512  ' from ADS_USER_FLAG_ENUM
     
Set objTemplate = GetObject("LDAP://cn=" & strTemplateUser & _
                            "," & strParentDN)
Set objParent   = GetObject("LDAP://" & strParentDN)
Set objUser     = objParent.Create("user", "cn=" & strNewUser)
     
objUser.Put "sAMAccountName", strNewUser
    
for each strAttr in arrAttrs
   objUser.Put strAttr, objTemplate.Get(strAttr)
next
     
objUser.SetInfo
objUser.SetPassword(strPassword)
objUser.SetInfo

objUser.Put "userAccountControl", ADS_UF_NORMAL_ACCOUNT
objUser.AccountDisabled = FALSE
objUser.SetInfo

WScript.Echo "Successfully created user"

Hope this helps.



Thanks

John Fuhrman
Titan Global Services
 
how can I use this to create 100 of users? Before I used to use csvde to create users from excel.
 
You could probably add this code to your other script.

Set the 'objTemplate =' to the user you wish to use for a template.
Then feed the results from your csvde into the variables

Code:
arrAttrs        = Array("department","co","title","l", "c", "st")
strParentDN     = "<ParentContainer>"   ' e.g. cn=Users,dc=rallencorp,dc=com
strTemplateUser = "<TemplateUserName>"  ' e.g. template-user-sales
strNewUser      = "<NewUserName>"       ' e.g. jdoe
strPassword     = "<Password>"




Thanks

John Fuhrman
Titan Global Services
 
I am not sure how to do that, do you have any article I can read and try.
 
What about mail box? how do I create mail box with the script?
 
You may need to look into LDIFDE. Here's a resource for you.


I use vbscript to parse and build ldifde files to import account with mailboxes into AD. Works nicely, but a lot of work and testing up front!

Hope This Helps,

Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top