WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Add a user to a OU


Question:

How can I create a new user account directly in organization-Unit (OU) on a win2000 DC?

I know how to create a "normal" account but in this case i have only right to create a user on this OU.

Is it possible with the ADSI-Extender?

Answer:

Here is an example of how it is done with the ADSI extender:
AdsiPath = "LDAP://birch/OU=myou,DC=mysubdomain,DC=mydomain,DC=com" 

; Create a user object
sObjectClass = "User"
sUserName = "CN=Roger Rabbit" 
sObjectpath2 = dsCreateObj(sAdsipath, sObjectClass, sUserName)

; Set the manditory properities.
sProperty = "samAccountName"
sValue = "rogerr"
dsSetProperty(sObjectPath2, sProperty, sValue)


; Create the object in the ds.
dsSetObj(sObjectPath2)

; Set the password
dsSetPassword(sObjectPath2, "", "12buklemyshow")

; Disable the account for now.
UF_ACCOUNTDISABLE = 2
nValue = dsGetProperty( sObjectPath2, "userAccountControl")
nValue = nValue ^ UF_ACCOUNTDISABLE
dsSetProperty(sObjectPath2, "userAccountControl", nValue)

Article ID:   W15800
File Created: 2004:03:30:15:40:56
Last Updated: 2004:03:30:15:40:56