[python-ldap] Ldap search doesn't return all attributes required

Francisco Méndez fmendezpalma at gmail.com
Wed Jun 13 10:23:02 CEST 2012


Hi,

I'm new in the list, I hope I'll find some help here. Thanks in advance.

I'm trying to do a simple search in a LDAP directory.  From a main routine,
I call two functions: one to connect to the LDAP directory (I just want to
make a search, so I do not bind) and then, I call the function that makes
the search. The problem: not all atributtes are returned, I have no way to
get "employeeNumber" attribute. No error given. Other attributes (cn,
homeDirectory) are returned correctly.

MAIN ROUTINE

*[...]*
*l.connect2()*
*filter="(cn=*)"*
*search  =
l.search2("ou=People",filter,["cn","employeeNumber","homeDirectory"])*
*[...]*



LDAP CONNECT CLASS

*[...]*
*    def connect2(self):*
*        ## first you must open a connection to the server*
*        try:*
*            self.connection = ldap.open("172.23.36.5")*
*            self.connection.protocol_version = ldap.VERSION3*
*        except ldap.LDAPError, e:*
*            print e*
*
*
*def search2(self,baseDN,filter,retrieveAttributes):*
*        searchScope = ldap.SCOPE_SUBTREE*
*        import pdb*
*        try:*
*            ldap_result_id = self.connection.search(baseDN+
",dc=instituto,dc=extremadura,dc=es", ldap.SCOPE_SUBTREE, filter,
retrieveAttributes)*
*            result_set = []*
*            while 1:*
*                result_type, result_data =
self.connection.result(ldap_result_id, 0)*
*                pdb.set_trace()*
*                if (result_data == []):*
*                    break*
*                else:*
*                    if result_type == ldap.RES_SEARCH_ENTRY:*
*                        result_set.append(result_data)*
*            return result_set*
*        except ldap.LDAPError, e:*
*            print e*
*[...]*



employeeNumber attribute (from LDAP)
employeeNumberDescripciónRFC2798: numerically identifies an employee within
an organizationOID2.16.840.1.113730.3.1.3ObsoletoNoHereda
de<http://ldap/phpldapadmin/cmd.php?cmd=schema&server_id=1&view=attributes&viewvalue=>
IgualdadcaseIgnoreMatch<http://ldap/phpldapadmin/cmd.php?cmd=schema&server_id=1&view=matching_rules&viewvalue=caseIgnoreMatch>
Ordenación(no especificado)Regla de subcadenacaseIgnoreSubstringsMatch
SintáxisDirectory String
(1.3.6.1.4.1.1466.115.121.1.15)<http://ldap/phpldapadmin/cmd.php?cmd=schema&server_id=1&view=syntaxes&highlight_oid=1.3.6.1.4.1.1466.115.121.1.15>
UnivaludadoSíColectivoNoModificado por el usuarioSíUso(no especificado)Longitud
máxima(no aplicable)Alias(ninguno)Usado por la clase de
objetoinetOrgPerson<http://ldap/phpldapadmin/cmd.php?cmd=schema&server_id=1&view=objectclasses&viewvalue=inetorgperson>Forzar
a MAY por configuraciónNo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20120613/6452ca00/attachment.html>


More information about the python-ldap mailing list