top
Loading...
如何通過編程為組添加成員
概要
本文討論如何使用 Active Directory Service Interfaces (ADSI) 2.0 和 VBScript 通過編程將成員添加至 Site Server 3.0 Membership Directory 的某個特定組中。

更多信息
按照下列步驟將某個成員添加至 Site Server 3.0 的一個組中:

綁定要添加用戶的組。


根據要添加至組(成員必須存在)的用戶的公用名稱 (CN) 創建新 MemberOf 對象。


將 MemberObject 屬性設置為要添加用戶的辨別名稱 (DN)。


下列代碼演示了該過程:
Dim adsMemberOf
Dim adsGroup
Dim strLdapSrv
Dim strMemberPath, strUserCn, strUserDn, _
strGroupDn, strAdmin, strAdminPwd

strLdapSrv = "LDAP://localhost:5292"
strMemberPath = ",ou=Members,o=Microsoft"
strUserCn = "cn=JohnDoe"
strUserDn = strUserCn + strMemberPath
strGroupDn = strLdapSrv +
"/o=Microsoft/ou=Groups/cn=Public"
strAdmin = "cn=Administrator,ou=Members,o=Microsoft"
strAdminPwd = "password"

'Bind to the specific group using Administrator credentials
Set adsGroup = GetObject("LDAP:")
Set adsGroup = adsGroup.OpenDSObject(strGroupDn, strAdmin, _
strAdminPwd, CLng(0))

'Create the new 'memberOf' object that will be stored in the
group
Set adsMemberOf = adsGroup.Create("memberof", strUserCn)
'Add the path to the user and store it in the 'memberObject'
property
adsMemberOf.Put "memberobject", CStr(strUserDn)

'Flush the property cache and update the directory
adsMemberOf.SetInfo

'Destroy the objects
Set adsMemberOf = Nothing
Set adsGroup = Nothing

參考
Active Directory Service Interfaces version 2.0 位于 Microsoft Developer Network Library/SDK Documentation/Platform SDK/Networking and Distributed Services 上。

關鍵字:prodsitesrv3
問題類型:
問題類型技術:

北斗有巢氏 有巢氏北斗