Quote:

Creating Users on Member Servers and Windows 2000 Professional
[This is preliminary documentation and subject to change.]

To create a user on a member server or computer running Windows 2000 Professional

Bind to the computer using the following rules:
Use an account that has sufficient rights to access that computer.
Use the following binding string format using the WinNT provider, computer name, and an extra parameter to tell ADSI that it is binding to a computer:
<a href="WinNT://sComputerName" target="_blank">WinNT://sComputerName</a>, computer

where sComputerName is the name of the computer who groups you want to access.

In the binding string, the ",computer" parameter tells ADSI that it is binding to a computer and allows the WinNT: provider's parser to skip some ambiguity resolution queries to determine what type of object you are binding to.

Bind to the IADsContainer interface.
Specify "user" as the class using IADsContainer::Create to add the user.
Write the user to the computer's security database using IADs::SetInfo.






This code should work but is currently giving me an error on my computer. Maybe I screwed something up... Your mileage may vary...
Code:
break On

$Server = "Bullockha"
$oComputer = GetObject("WinNT://" + $Server + ",computer")
? ConvertCOMerror(@error)
$oUser = $oComputer.Create("user", "MyNewUser")
? ConvertCOMerror(@error)
$oUser.SetPassword("NewPassword")
? ConvertCOMerror(@error)
$oUser.SetInfo
? ConvertCOMerror(@error)

Function ConvertCOMerror($error)
$error = val("&"+Right(DecToHex($error),4))
? "Error: $error"
shell "net helpmsg $error"
Endfunction



[edit]
The problem was that we enforce STRONG passwords via policy and "NewPassword" did not meet those requirements.

$oUser.SetPassword("NewPassword2")

made the program work.

[/edit]


Edited by Howard Bullock (2004-02-22 04:48 PM)
_________________________
Home page: http://www.kixhelp.com/hb/