473,597 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
Greetings,

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:

initialize(uri)
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
  6.  
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
0 1719

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

Similar topics

1
2188
by: Brian Beck | last post by:
As far as I can tell, both maintainers of the Windows builds of Python-LDAP haven't updated in about a year. This doesn't exactly make the builds ancient or obsolete, but it would be nice to start fresh with the latest version. I've tried without success in building it myself. The hardest part is simply that Python-LDAP is dependent on at LEAST two other projects -- OpenLDAP and Cyrus SASL. This increases the difficulty three-fold. ...
1
4741
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I have a page in a folder (under anonymous authentication in IIS6) that has a link on it that...
1
4837
by: Nico Grubert | last post by:
Hi there, on a linux machine I am running this ldapsearch from the command line: ldapsearch -x -h myldaphost.mydomain.com \ -D "CN=ldapuser,CN=Users,DC=mydomain,DC=com" -w "secret" \ -b "CN=ANYCOMPUTER,CN=Computers,DC=mydomain,DC=com" How can I do this with python-ldap?
0
1030
by: sallas | last post by:
I am trying to connect to a Active Directory on a Windows server from either a Debian machine or a Windows XP machine using Python. So far I can connect using the following: import sys import ldap def main(): who = "me" pwd = "shhhh" try: l = ldap.initialize('ldap://myServer.com')
6
7772
by: hotani | last post by:
I am attempting to pull info from an LDAP server (Active Directory), but cannot specify an OU. In other words, I need to search users in all OU's, not a specific one. Here is what works: con = ldap.initialize("ldap://server.local") con.simple_bind_s('user@domain', pass) result = con.search_ext_s( 'OU=some office, DC=server, DC=local',
2
2274
by: theiviaxx | last post by:
Thanks for the help guys, it works! I used the ldap.set_option(ldap.OPT_REFERRALS, 0) from http://peeved.org/blog/2007/11/20/ immedialtey after import, then did the initialize trace_level=2 and did the simple_bind_s. I was able to search and get the results. That trace_level thing is nice, i'm sure i will be debugging this more as i move forward :) Not sure if this is an AD thing or just something i needed to do with our particular...
2
6479
by: Juan | last post by:
Hi I am trying to make a simple Python script using LDAP. The module is imported OK, but when I call the function open or initialize, I get this error: Traceback (most recent call last): File "/home/juan/workspace/amquare/src/nutum/amquare/amquare.py", line 122, in <module> conn.connect()
1
5437
by: Erick Perez - Quadrian Enterprises, S.A. | last post by:
Hi, I have a MS Windows AD domain, and have one OU with more tan 1000 users objects. When I try to read it, I hit the 1000 limit of AD while returning objects, so I'm asking for advice as to how to read them. Here is my actual code, it is not the cleanest as I am learning python. Suggestions are welcomed :) Runnig this script on RedHat 5.x with "python zimbra2.py" returns: {'info': '', 'desc': 'Size limit exceeded'}
0
7883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8263
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5842
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5421
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3876
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2393
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.