Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-04-2008, 10:21 AM   #1
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,071
Blog Entries: 1

Rep: Reputation: 90
Question python-ldap: How to catch an error on binding?

I'm just giving my first baby steps on python-ldap.

I have on purpose set up a connection that has to fail on binding... but I don't get to catch an error:

import ldap
import sys
ldapURI = "ldap://" + ldapServer + ":" + str(ldapPort)
print "LDAP URI: " + ldapURI
ldapConn = ldap.initialize(ldapURI)
    ldapConn.bind(ldapLoginID, ldapLoginPasswd, ldap.AUTH_SIMPLE)
    print "Caught an error!", sys.exc_info()
When I run it, this is the output:
LDAP URI: ldap://
And this is the network trace:
1	0.000000	TCP	55961 > ldap [SYN] Seq=0 Win=5840 Len=0 MSS=1460 TSV=22309611 TSER=0 WS=6
2	0.000318	TCP	ldap > 55961 [SYN, ACK] Seq=0 Ack=1 Win=5792 Len=0 MSS=1460 TSV=16565465 TSER=22309611 WS=5
3	0.000357	TCP	55961 > ldap [ACK] Seq=1 Ack=1 Win=5888 Len=0 TSV=22309612 TSER=16565465
4	0.000434	LDAP	bindRequest(1) "cn=root,dc=fake,dc=domain,dc=com" simple 
5	0.000642	TCP	ldap > 55961 [ACK] Seq=1 Ack=49 Win=5792 Len=0 TSV=16565465 TSER=22309612
6	0.002085	LDAP	bindResponse(1) invalidCredentials 
7	0.002144	TCP	55961 > ldap [ACK] Seq=49 Ack=15 Win=5888 Len=0 TSV=22309612 TSER=16565465
8	0.004096	LDAP	unbindRequest(2) 
9	0.004144	TCP	55961 > ldap [FIN, ACK] Seq=56 Ack=15 Win=5888 Len=0 TSV=22309612 TSER=16565465
10	0.004172	TCP	55961 > ldap [RST, ACK] Seq=57 Ack=15 Win=5888 Len=0 TSV=22309612 TSER=16565465
How can I catch that problem in the code?


ldap, python

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues Building Python-ldap Pratt Slackware 5 07-24-2008 05:45 PM
RHEL5 to Windows CA, Apache2/LDAP BINDing adrianmarsh Red Hat 1 04-05-2008 05:07 AM
LDAP binding error with Apache & Subversion rangel59 Linux - Software 16 03-18-2008 11:45 AM
Python: catch stdout and stderr from external command Ephracis Programming 9 02-28-2008 09:57 AM
LDAP not binding shane200_ SUSE / openSUSE 1 08-09-2005 11:56 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:41 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration