基于ADSI的NT帐号及Exchange Server帐号申请及验证模块源代码[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 zhengsb 的 blog

        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, _

本文关键:ADSI NT Exchange 帐号
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top