By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

python ldap: what happens when ldap.initialize() is given a bad uri?

P: 1

My ldap application relies on user input for a ldap server uri, so I am looking for a way to use the ldap api to determine whether the ldap server is up or not.
All the docs have to say is this:

Opens a new connection with an LDAP server, and return an LDAP object (see 1.1.4) used to perform operations on that server. Parameter uri has to be a valid LDAP URL.

Expand|Select|Wrap|Line Numbers
  1. server = "ldap://666.222.111.333"
  2. try:
  3.     l = ldap.initialize(server)
  4. except ldap.LDAPError, errorMsg:
  5.     print errorMsg
When I run this code, no exception is raised, but there is clearly no ldap server running at that invalid ip address. If I try doing a bind afterwards, I can get an exception to be raised, but I have had unpredictable results in the amount of time (even using result()) that this takes.

Is initialize actually trying to make a connection?
If so, how can I find out if the connection failed without doing a bind?

I'm running python 2.4.2 on SUSE Linux Enterprise Desktop v. 10.
Apr 19 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.