Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get groupMembership

Status
Not open for further replies.

keeskas

Technical User
Oct 22, 2005
2
NL
Hi,

Looking for a small vbs (or asp) example to read all the groups a user is member of (or viceversa all members of a group) i got this working in a AD ldap configuration, now i need to do this against a novell E-directory LDAP.

getting confused with how to read "groupMembership"

can some show me which way to go

this works against AD ldap

Code:
Attribute VB_Name = "ldapstuff"

Public Function ismemberof(sLdapusr As String, sLdapadr As String, sLdapgrp As String) As Boolean

On Error GoTo Errhandler

sLdapusr = LCase(sLdapusr)
sLdapadr = LCase(sLdapadr)
sLdapgrp = LCase(sLdapgrp)

Set objUser = GetObject("LDAP://cn=" & sLdapusr & "," & sLdapadr)
arrstrGroups = objUser.GetEx("memberOf")

If Err.Number <> 0 Then
  On Error GoTo 0
  strgroups = ""
Else
  On Error GoTo 0
  strgroups = LCase(Join(arrstrGroups))
End If

If InStr(strgroups, "cn=" & sLdapgrp & ",") > 0 Then
  ismemberof = True
Else
  ismemberof = False
End If

GoTo FunctionEnd

Errhandler:

ismemberof = False
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top