In <34110eed-96bc-499f-9a4e-068f2720f...@h12g2000pro.googlegroups.com> sajuptpm <sajup...@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 gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list