byval dwacerevision as long, _
byval accessmask as long, _
psid as byte) as long
declare function isvalidacl lib "advapi32.dll" _
(pacl as byte) as long
declare function getlasterror lib "kernel32" _
() as long
declare function lookupaccountname lib "advapi32.dll" _
alias "lookupaccountnamea" _
(byval ipsystemname as string, _
byval ipaccountname as string, _
psid as byte, _
cbsid as long, _
byval referenceddomainname as string, _
cbreferenceddomainname as long, _
peuse as integer) as long
declare function netgetdcname lib "netapi32.dll" _
(servername as byte, _
domainname as byte, _
dcnptr as long) as long
declare function netapibufferfree lib "netapi32.dll" _
(byval ptr as long) as long
declare function ptrtostr lib "kernel32" _
alias "lstrcpyw" (retval as byte, byval ptr as long) as long
declare function getlengthsid lib "advapi32.dll" _
(psid as byte) as long
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'' create_nt_account() -- creates an nt user account
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public function create_nt_account(strdomain as string, _
stradmin as string, _
strpassword as string, _
username as string, _
fullname as string, _
ntserver as string, _
strpwd as string, _
strrealname as string) as boolean
dim ons as iadsopendsobject
dim user as iadsuser
dim domain as iadsdomain
on error goto create_nt_account_error
create_nt_account = false
if (strpassword = "") then
strpassword = ""
end if
set ons = getobject("winnt:")
set domain = ons.opendsobject("winnt://" & strdomain, strdomain & "\" & stradmin, strpassword, 0)
set user = domain.create("user", username)
with user
.description = "adsi 创建的用户"
.fullname = strrealname 'fullname
'.homedirectory = "\\" & ntserver & "\" & username
'.loginscript = logon_cmd
.setinfo
' first password = username
.setpassword strpwd
end with
debug.print "successfully created nt account for user " & username
create_nt_account = true
exit function
create_nt_account_error:
create_nt_account = false
debug.print "error 0x" & cstr(hex(err.number)) & " occurred creating nt account for user " & username
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'' delete_nt_account() -- deletes an nt user account
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public function delete_nt_account(strdomain as string, _
stradmin as string, _