基于adsi的nt帐号及exchange server帐号申请及验证模块源代码
1.安装adsi2.5
2.创建一个新的activex dll工程,工程名:rbsboxgen,类名:ntusermanager
3.执行工程-引用将下列库选上:
active ds type library
microsoft active server pages object library
4.添加一个模块,代码如下:
'模块
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
'' adsi sample to create and delete exchange 5.5 mailboxes
''
'' richard ault, jean-philippe balivet, neil wemple -- 1998
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
option explicit
' mailbox property settings
public const logon_cmd = "logon.cmd"
public const incoming_message_limit = 1000
public const outgoing_message_limit = 1000
public const warning_storage_limit = 8000
public const send_storage_limit = 12000
public const replication_sensitivity = 20
public const country = "us"
' mailbox rights for exchange security descriptor (home made)
public const right_modify_user_attributes = &h2
public const right_modify_admin_attributes = &h4
public const right_send_as = &h8
public const right_mailbox_owner = &h10
public const right_modify_permissions = &h80
public const right_search = &h100
' win32 constants for security descriptors (from vb5 api viewer)
public const acl_revision = (2)
public const security_descriptor_revision = (1)
public const sidtypeuser = 1
type acl
aclrevision as byte
sbz1 as byte
aclsize as integer
acecount as integer
sbz2 as integer
end type
type ace_header
acetype as byte
aceflags as byte
acesize as long
end type
type access_allowed_ace
header as ace_header
mask as long
sidstart as long
end type
type security_descriptor
revision as byte
sbz1 as byte
control as long
owner as long
group as long
sacl as acl
dacl as acl
end type
' just an help to allocate the 2dim dynamic array
private type mysid
x() as byte
end type
' declares : modified from vb5 api viewer
declare function initializesecuritydescriptor lib "advapi32.dll" _
(psecuritydescriptor as security_descriptor, _
byval dwrevision as long) as long
declare function setsecuritydescriptorowner lib "advapi32.dll" _
(psecuritydescriptor as security_descriptor, _
powner as byte, _
byval bownerdefaulted as long) as long
declare function setsecuritydescriptorgroup lib "advapi32.dll" _
(psecuritydescriptor as security_descriptor, _
pgroup as byte, _
byval bgroupdefaulted as long) as long
declare function setsecuritydescriptordacl lib "advapi32.dll" _
(psecuritydescriptor as security_descriptor, _
byval bdaclpresent as long, _
pdacl as byte, _
byval bdacldefaulted as long) as long
declare function setsecuritydescriptorsacl lib "advapi32.dll" _
(psecuritydescriptor as security_descriptor, _
byval bsaclpresent as long, _
psacl as byte, _
byval bsacldefaulted as long) as long
declare function makeselfrelativesd lib "advapi32.dll" _
(pabsolutesecuritydescriptor as security_descriptor, _
pselfrelativesecuritydescriptor as byte, _
byref lpdwbufferlength as long) as long
declare function getsecuritydescriptorlength lib "advapi32.dll" _
(psecuritydescriptor as security_descriptor) as long
declare function isvalidsecuritydescriptor lib "advapi32.dll" _
(psecuritydescriptor as byte) as long
declare function initializeacl lib "advapi32.dll" _
(pacl as byte, _
byval nacllength as long, _
byval dwaclrevision as long) as long
declare function addaccessallowedace lib "advapi32.dll" _
(pacl as byte, _