How do I create a new user in NT using ADSI?

A. Use the following ADSI script.

On Error Resume Next
strUser="UserID"
Set oDomain=GetObject("WinNT://YourDomain")
Set oUser=oDomain.Create ("user", strUser)
If (err.number=0) Then 'If not 0 then user ID already exists
 oUser.SetInfo
oUser.SetPassword "mypassword"
oUser.SetInfo
End If

To update other elements of information you can use

set user=GetObject("WinNT://domain/user")
 User.FullName=FirstNameVar
 User.HomeDirectory=UserHome
 User.Profile="\\Server\Share\user"
 User.LoginScript=LogonScript
 User.Description="Description"
User.setinfo

For more FAQ's see the WSH FAQ at http://wsh.glazier.co.nz/frame.asp?target=faq/wshfaq.asp


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish