Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8383
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!panix!gordon |
|---|---|
| From | John Gordon <gordon@panix.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: LDAP: How get all users belongs to a group. |
| Date | Fri, 24 Jun 2011 14:57:37 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 43 |
| Message-ID | <iu28l1$5ob$1@reader1.panix.com> (permalink) |
| References | <542151da-ebfb-4cfb-b83d-14f2ba641bf4@x38g2000pri.googlegroups.com> <iu1ki7$9lt$2@dont-email.me> <34110eed-96bc-499f-9a4e-068f2720fc8b@h12g2000pro.googlegroups.com> |
| NNTP-Posting-Host | panix1.panix.com |
| X-Trace | reader1.panix.com 1308927457 5899 166.84.1.1 (24 Jun 2011 14:57:37 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Fri, 24 Jun 2011 14:57:37 +0000 (UTC) |
| User-Agent | nn/6.7.3 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:8383 |
Show key headers only | View raw
In <34110eed-96bc-499f-9a4e-068f2720fc8b@h12g2000pro.googlegroups.com> sajuptpm <sajuptpm@gmail.com> writes:
> dn: cn=My-Group-1,ou=Groups,o=CUST
> member: cn=AJP2203,ou=Internal PCA,o=CUST
> member: cn=AZE9632,ou=Internal PCA,o=CUST
> member: cn=BTC4979,ou=Internal PCA,o=CUST
> * I have group definition in LDAP server as above.
> * How fetch all members from this perticular group 'My-Group-1' using
> python-ldap module.
> * I tried, but i don't know how do it.
> * I want to get those 3 members from group 'My-Group-'
This code should work, although I haven't tested it:
import ldap
uri = "my hostname and port"
user = "my username"
password = "my password"
ldapClient = ldap.initialize(uri)
ldapClient.set_option(ldap.OPT_REFERRALS, 0)
ldapClient.bind(user, password)
results = ldapClient.search_s("cn=My-Group-1,ou=Groups,o=CUST", ldap.SCOPE_BASE)
for result in results:
result_dn = result[0]
result_attrs = result[1]
if "member" in result_attrs:
for member in result_attrs["member"]:
print member
ldapClient.unbind_s()
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
LDAP: How get all users belongs to a group. sajuptpm <sajuptpm@gmail.com> - 2011-06-23 06:14 -0700
Re: LDAP: How get all users belongs to a group. Ken Watford <kwatford+python@gmail.com> - 2011-06-23 09:59 -0400
Re: LDAP: How get all users belongs to a group. Michael Ströder <michael@stroeder.com> - 2011-06-24 11:14 +0200
Re: LDAP: How get all users belongs to a group. sajuptpm <sajuptpm@gmail.com> - 2011-06-24 02:58 -0700
Re: LDAP: How get all users belongs to a group. sajuptpm <sajuptpm@gmail.com> - 2011-06-24 03:06 -0700
Re: LDAP: How get all users belongs to a group. sajuptpm <sajuptpm@gmail.com> - 2011-06-24 03:16 -0700
Re: LDAP: How get all users belongs to a group. Michael Ströder <michael@stroeder.com> - 2011-06-24 13:02 +0200
Re: LDAP: How get all users belongs to a group. John Gordon <gordon@panix.com> - 2011-06-24 14:57 +0000
Re: LDAP: How get all users belongs to a group. sajuptpm <sajuptpm@gmail.com> - 2011-06-25 00:08 -0700
Re: LDAP: How get all users belongs to a group. Michael Ströder <michael@stroeder.com> - 2011-06-25 12:20 +0200
csiph-web