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 = %26amp;H2
Public Const RIGHT_MODIFY_ADMIN_ATTRIBUTES = %26amp;H4
Public Const RIGHT_SEND_AS = %26amp;H8
Public Const RIGHT_MAILBOX_OWNER = %26amp;H10
Public Const RIGHT_MODIFY_PERMISSIONS = %26amp;H80
Public Const RIGHT_SEARCH = %26amp;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, _
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" _
如果您对本文有任何疑问或者建议,请到讨论区发表您的意见:
>>
论坛入口 <<
上一篇:Exchange 集群简介 下一篇:与注册表相关的Exchange复制失败
【文章评论】
【收藏本文】
【推荐好友】
【打印本文】
【我要投稿】 【论坛讨论】