[python-ldap] How do i know if bind was successful?

Anurag Chourasia anurag.chourasia at gmail.com
Mon Apr 22 10:27:28 CEST 2013


Hi Michael,

Also, the whoami_s works fine with MS ADAM but not with Apache Server
Studio. Here is a transcript for each one of those

*MS ADAM*
>>> result=l.bind(who,cred)
>>> l.result(result)
(97, [])
>>>
>>> l.whoami_s()
'dn:CN=anurag,OU=Appl Groups,OU=Central,OU=CL,DC=c.corp,O=App,C=US'

*
*
*Apache Server Studio*
>>> l.result(result)
(97, [])
>>> l.whoami_s()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\ldap\ldapobject.py", line 596, in
whoami_s

    return self._ldap_call(self._l.whoami_s,serverctrls,clientctrls)
  File "C:\Python27\lib\site-packages\ldap\ldapobject.py", line 99, in
_ldap_call
    result = func(*args,**kwargs)
ldap.PROTOCOL_ERROR: {'info': 'Unrecognized extended operation
EXTENSION_OID: 1.3.6.1.4.1.4203.1.11.3', 'desc': 'Protocol error'}

Regards,
Anurag

On Mon, Apr 22, 2013 at 4:22 AM, Anurag Chourasia <
anurag.chourasia at gmail.com> wrote:

> Hi Michael,
>
> Thanks for your response.
>
> Please note that if i supply a wrong password then the bind step gives me
> an error *ldap.INVALID_CREDENTIALS*
>
> With the correct password it does not throw any exception as such....
>
> If i use Apache Directory Studio instead of MS ADAM for my tests then the
> Search function works fine despite the bind having given the same results
> as in my original problem transcript.
>
> Here is a session transcript with Apache Server Studio
>
> >>> import ldap
> >>> l=ldap.initialize('ldap://127.0.0.1:10389')
> >>> who="uid=admin,ou=system"
> >>> cred="123456"
> >>> result=l.bind(who,cred)
> >>> l.result(result)
> (97, [])
> >>> l.search_s('OU=Appl Groups,OU=Central,OU=CL,DC=cen,DC=corp', 0,
> '(objectClass=*)')
> [('OU=Appl Groups,OU=Central,OU=CL,DC=cencosud,DC=corp', {'objectClass':
> ['organizationalUnit', 'top'], 'ou': ['Appl Groups']})]
>
> Regards,
> Anurag
>
>
> On Mon, Apr 22, 2013 at 3:32 AM, Michael Ströder <michael at stroeder.com>wrote:
>
>> Anurag Chourasia wrote:
>> > I am exploring python-ldap and I have the following question.
>> >
>> > I am testing using ADAM on Windows XP.
>> >
>> > How could i know if my bind request was successful.
>>
>> After a successful simple bind operation the server returns a LDAP
>> response
>> with error code ok (0) => no LDAPError exception raised.
>>
>> Which authorization identity is in effect can be queried by LDAP Who Am I?
>> extended operation if the server supports it:
>>
>> http://www.python-ldap.org/doc/html/ldap.html#ldap.LDAPObject.whoami_s
>>
>> Not sure whether MS ADAM supports it though.
>>
>> > This is my session transcript.
>> >
>> >>>> import ldap
>> >>>> l=ldap.initialize('ldap://localhost:389')
>> >>>> who="CN=achourasia,OU=Appl
>> > Groups,OU=Central,OU=CL,DC=cencosud.corp,O=App,C=US"
>> >>>> cred="Jaisai1"
>> >>>> result=l.bind(who,cred)
>> >>>> l.result(result)
>> > (97, [])
>> >>>>
>> >
>> > What is 97 above supposed to mean? When a exception is not thrown then
>> does it
>> > mean that the request was successful?
>>
>> Please read first about the difference of synchronous and asynchronous
>> operation methods:
>>
>> http://www.python-ldap.org/doc/html/ldap.html#sending-ldap-requests
>>
>> You probably want to use simple_bind_s():
>>
>>
>> http://www.python-ldap.org/doc/html/ldap.html#ldap.LDAPObject.simple_bind_s
>>
>> bind_s() is nowadays just a thin wrapper around simple_bind_s().
>>
>> Ciao, Michael.
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20130422/61802c3a/attachment.html>


More information about the python-ldap mailing list