code:
Function UserCreate($target,$user,OPTIONAL $rightstouse)
;UserCreate Function
;
;Syntax:
; UserRename(<Domain/computer>,<userid>,[rights to use])
; <domain/computer> = the domain or computer you want to create a new account in
; <userid> = the name of the account to create
; [rights to use] = optional user name and password used to make the account
;
;Examples:
; ;This will create a user account called "thing1" in the local domain
; UserCreate(@domain,"Thing1")
;
; ;This will create a user account called thing2 on the workstation
; ;beanbag in the kixtart domain
; usercreate("kixtart/beanbag","thing2")
;
; ;This will create a user account called thing3 on the workstation
; ;beanbag in the kixtart domain, using the local Administrator account
; usercreate("kixtart/beanbag","thing2","beanbag\administrator|password") if $rightstouse
$rightstouse = split($rightsToUse,"|")
if ubound($rightstouse) <> 1 exit(1) endif
? $rightstouse[0]
? $rightstouse[1]
if instr($target,"/") <> 0
$target = getobject("WinNT:").OpenDSObject("WinNT://$target,computer",$rightstouse[0],$rightstouse[1], 2)
if @error <> 0 and vartype($target) <> 9 exit(@error) endif
else
$target = getobject("WinNT:").OpenDSObject("WinNT://$target",$rightstouse[0],$rightstouse[1],2)
if @error <> 0 and vartype($target) <> 9 exit(@error) endif
endif
else
if instr($target,"/") <> 0
$target = getobject("WinNT://$target,computer")
if @error <> 0 and vartype($target) <> 9 exit(@error) endif
else
$target = getobject("WinNT://$target")
if @error <> 0 and vartype($target) <> 9 exit(@error) endif
endif
endif
$user = $target.create("user","$user")
if @error <> 0 and vartype($user) <> 9 exit(@error) endif
$user.setinfo
exit(@error)
endfunction