K
K
Konstantin Gorodetsky2015-04-18 05:55:55
Python
Konstantin Gorodetsky, 2015-04-18 05:55:55

How to know if a user is a member of a specific LDAP group?

# -*- coding: utf-8 -*-
import win32com.client
query = "<LDAP://DC=DOM,DC=TAN,DC=CORP>;(&(sAMAccountName={0})(objectClass=user));*;subTree".format(curUser)
rs = LDAPConn.Execute(query)[0]
obj = win32com.client.GetObject(rs.Fields(0).Value)
userFIO = obj.Name.split("=")[1]

I find a specific user. Now you need to check if he is a member of a specific group? There is an IsMember() method, but I don't know how to apply it yet...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey N, 2015-06-04
@Albibek

The list of groups (as group DNs) of which the user is a member is stored in the memberOf LDAP attribute. Read it and you will be happy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question