VB Script for New User on AD

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mikael
    New Member
    • Nov 2006
    • 16

    VB Script for New User on AD

    Help! I am getting an error in this script. It is my first attempt at creating a script to create a new user in Active Directory.

    Code:
    'New User
    
    firstname = InputBox("Enter First Name: ")
    lastname = InputBox("Enter Last Name: ")
    username = InputBox("Enter username: ")
    
    
    Set objOU = GetObject("LDAP://OU=xxx,dc=xxx,dc=xxx")
    
    Set objUser = objOU.Create("User", "cn=" & username)
    
    objUser.Put "sAMAccountName", username
    objUser.Put "Description", "Intern"
    
    objUser.SetPassword "W3lcome"
    
    objUser.AccountDisabled = False
    
    objUser.Put "givenName", firstname
    
    objUser.Put "sn", lastname
    
    strNewProfilePath = "\\servername\Profiles\" & username
    objUser.Put "profilePath", strNewProfilePath
    
    objUser.Put "scriptPath", "logon.wsf"
    
    objUser.Put "homeDirectory", "\\servername\Users" & username
    objUser.Put "homeDrive", "H:"
    
    objUser.SetInfo

    The Error is: There is no such object on the server.
    It is occuring at char 1 of: objUser.SetPass word "W3lcome"

    Thanks for the help all!
    Last edited by willakawill; Feb 23 '07, 10:36 PM. Reason: please use code tags when posting code
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Moved you here. Thought you might get a better response

    Comment

    • Cyberdyne
      Recognized Expert Contributor
      • Sep 2006
      • 627

      #3
      Mikael take a look at THIS from microsoft as it contains script information relevant to your task.

      Cyber.

      Comment

      Working...