home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / SiteServer / AddToGroup / AddToGroup.bas next >
Encoding:
BASIC Source File  |  1999-03-10  |  1.1 KB  |  39 lines

  1. Attribute VB_Name = "AddToGroup"
  2. Sub Main()
  3.  
  4. '-- adopted from Site Server Knowledge Base
  5. Dim adsMemberOf
  6. Dim adsGroup
  7. Dim strLdapSrv
  8. Dim strMemberPath, strUserCn, strUserDn, _
  9. strGroupDn, strAdmin, strAdminPwd
  10.  
  11. strLdapSrv = "LDAP://localhost:5292"
  12. strMemberPath = ",ou=Members,o=Microsoft"
  13. strUserCn = "cn=JohnDoe"
  14. strUserDn = strUserCn + strMemberPath
  15. strGroupDn = strLdapSrv + "/o=Microsoft/ou=Groups/cn=Public"
  16. strAdmin = "cn=Administrator,ou=Members,o=Microsoft"
  17. strAdminPwd = "password"
  18.  
  19.  
  20. 'Bind to the specific group using Administrator credentials
  21. Set adsGroup = GetObject("LDAP:")
  22. Set adsGroup = adsGroup.OpenDSObject(strGroupDn, strAdmin, _
  23. strAdminPwd, CLng(0))
  24.  
  25.  
  26. 'Create the new 'memberOf' object that will be stored in the group
  27. Set adsMemberOf = adsGroup.Create("memberof", strUserCn)
  28.  
  29. 'Add the path to the user and store it in the 'memberObject' property
  30. adsMemberOf.Put "memberobject", CStr(strUserDn)
  31.  
  32. 'Flush the property cache and update the directory
  33. adsMemberOf.SetInfo
  34.  
  35. 'Destroy the objects Set adsMemberOf = Nothing
  36. Set adsGroup = Nothing
  37.  
  38. End Sub
  39.