Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango user ldap to search all names from a group
    text
    copied!<pre><code>AD_DNS_NAME = xx.xxxxxx.org' AD_LDAP_URL = 'ldap://%s' % (AD_DNS_NAME) con = ldap.initialize(AD_LDAP_URL) username = 'john' password = '123' base_dn = 'OU=Domain Users,DC=xx,DC=xxxxx,DC=org' filter = '(sAMAccountName=' + username + ')' attrs = ['mail'] dn = '%s@%s' % (username, AD_DNS_NAME) try: con.simple_bind_s(dn, password) my_search = con.search_s(base_dn, ldap.SCOPE_SUBTREE, filter , attrs ) # my_search return #[('CN=john,OU=x_x_x xx,OU=xxxxxx,OU=CN BU,OU=Domain Users,DC=xx,DC=xxxxxx,DC=org', {'mail': ['john@xxxxxx.com.cn']})] </code></pre> <p>above code can search the info of a certain user named "john', but i don't know how to get all the members' name from a mail group, who know how to do this? for example, i want to search a group named "All of AAA"</p> <p>I set the attrs to null and get all the info as below: i delete some other unimportant info</p> <pre><code>[ ('CN=John,OU=C_E_S XX,OU=Mycity,OU=CN BU,OU=Domain Users,DC=xx,DC=xxxxxx,DC=org', { 'mailNickname': ['John'], 'primaryGroupID': ['513'], 'memberOf': [ 'CN=All of AAA,OU=CN BU,OU=Distribution List,OU=Exchange,DC=xx,DC=xxxxxx,DC=org', ], } ) ] </code></pre> <p>could you please tell me how can i set the filter: filter = '(&amp;(objectClass=group)(CN=groupname))' set group='memberOf' and groupname='All of AAA' ???, i have tried this but it does not help</p> <p>I have resovle this problem, now i write down the method:</p> <pre><code>filter = "(&amp;(objectCategory=person)(objectClass=user)(memberOf=CN=All of AAA,OU=CN BU,OU=Distribution List,OU=Exchange,DC=xx,DC=xxxxxx,DC=org))" </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload