LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 09-04-2008, 09:21 AM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
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:

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


Reply

Tags
ldap, python



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 04:45 PM
RHEL5 to Windows CA, Apache2/LDAP BINDing adrianmarsh Red Hat 1 04-05-2008 04:07 AM
LDAP binding error with Apache & Subversion rangel59 Linux - Software 16 03-18-2008 10:45 AM
Python: catch stdout and stderr from external command Ephracis Programming 9 02-28-2008 08:57 AM
LDAP not binding shane200_ SUSE / openSUSE 1 08-09-2005 10:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:32 AM.

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