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

John Savill

March 4, 1999

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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="\ServerShareuser"
 User.LoginScript=LogonScript
 User.Description="Description"
User.setinfo

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

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like