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.

ADSI - Creating Computer Accounts

Keywords: 	 ADSI - Creating Computer Accounts

Question:

I want to be able to create workstation accounts on Active Directory through a script, however I am having a problem with a constraint violation error. I have confirmed that the ldap path is valid, that there are no outstanding rights that are lacking, and that the script's syntax is (so far as I can tell) accurate.

Can anyone let me know what the constraint violation might be?

AddExtender("WWADS34I.DLL")
;Sets user credentials 
username = askline("Active Directory - Create Workstation","Your Name:","")
userpassword = askpassword("Active Directory - Create Workstation","Your password:")
dsSetCredent(username, userpassword)

sASDIPath = "LDAP:COMPLETE LDAP PATH GOES HERE"
sObjectClass = "Computer"
sComputerName = askline ("Active Directory - Create Workstation","Workstation name:","")
sObjectPath = dsCreateObj(sASDIPath, sObjectClass, StrCat("CN=",sComputerName))
dsSetObj(sObjectPath)

message ("Active Directory - Create Workstation","All done!")


exit

Answer:

You have to set the sAMAccountName property to StrUpper(StrCat(Computername,"$"))
dsSetProperty(sComputerPath, "samAccountName", StrUpper(StrCat(sComputerName, "$")))

Article ID:   W15379
File Created: 2007:06:29:11:58:36
Last Updated: 2007:06:29:11:58:36