473,819 Members | 1,959 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ldapsearch example in python-ldap?

Hi there,

on a linux machine I am running this ldapsearch from the command line:

ldapsearch -x -h myldaphost.mydo main.com \
-D "CN=ldapuser,CN =Users,DC=mydom ain,DC=com" -w "secret" \
-b "CN=ANYCOMPUTER ,CN=Computers,D C=mydomain,DC=c om"

How can I do this with python-ldap?

Regards,
Nico
Nov 23 '06 #1
1 4845
Nico Grubert wrote:
>
on a linux machine I am running this ldapsearch from the command line:

ldapsearch -x -h myldaphost.mydo main.com \
-D "CN=ldapuser,CN =Users,DC=mydom ain,DC=com" -w "secret" \
-b "CN=ANYCOMPUTER ,CN=Computers,D C=mydomain,DC=c om"

How can I do this with python-ldap?
http://python-ldap.sourceforge.net/docs.shtml contains some links to
introductions.

This command above boils down to:

l=ldap.initiali ze("ldap://myldaphost.mydo main.com")
l.simple_bind_s ("CN=ldapuser,C N=Users,DC=mydo main,DC=com","s ecret")
r = l.search_s(
"CN=ANYCOMPUTER ,CN=Computers,D C=mydomain,DC=c om",
ldap.SCOPE_SUBT REE, # this is the default of ldapsearch
"(objectClass=* )"
)

But you really should learn more about it by diving into:

http://python-ldap.sourceforge.net/d...p-objects.html

Ciao, Michael.
Nov 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2096
by: Phil Schmidt | last post by:
I'm attempting to follow the instructions at http://sebsauvage.net/python/mingw.html, without luck. I have Python 2.3, MinGW 3.2.3, ans SWIG 1.3.19. I get an export error on "initexample" when attempting the example. Do I need some extra switches to get SWIG to create that function? Or is it something else? Here's my example build:
11
3711
by: Maxim Khesin | last post by:
Hi, being recently introduced to the joys of programming in a powerful dynamic language (go snake!) I periodically rethink which parts of C++ I still miss. One thing I really enjoy is the generics of C++ - i think they are the single strong benefit of a strongly typed system. I was wondering about the possibility of implementing STL-like algorithms in Python and the one thing that I cannot think of doing without a kludge is the object...
10
2895
by: Dan Williams | last post by:
Ummmm... This is weird. Sorry if it's known about (how can it NOT be, I wonder?) but I haven't seen any reference to it anywhere. I'm running the latest Python (2.3.3) on Windows XP Pro, i386 architecture. Fire up python or whatever. Do this: Result:
1
7678
by: Srijit Kumar Bhadra | last post by:
Hello, Here are code snippets to create and access shared memory in Python with and without ctypes module. With regards, Srijit Filename : SharedMemCreate.py import msvcrt, mmap
3
12384
by: Xah Lee | last post by:
Split File Fullpath Into Parts Xah Lee, 20051016 Often, we are given a file fullpath and we need to split it into the directory name and file name. The file name is often split into a core part and a extension part. For example: '/Users/t/web/perl-python/I_Love_You.html' becomes
10
2303
by: notejam | last post by:
I am trying to get started with a interactive version of Python for windows and need some help. I have played with the tutorial, and now want to write a program. In basic language, I could write something like 10 print "hello" 20 print "Jim" and if I run it I would get hello
3
1368
by: millball54 | last post by:
Hey Everyone Let me tell you all a little bit about my programming background so you can get an idea of my capability, or lack of, dealing with p.l; so far i've learned some visual basic when i was doing my a-levels.... and thats about it lol. Basically i like the sound of python and its ease of use and would like to know in depth more about it and its range of useage. Please do tell me all you know, keeping in mind i am a n00b, so...
17
8493
by: frederic.pica | last post by:
Greets, I've some troubles getting my memory freed by python, how can I force it to release the memory ? I've tried del and gc.collect() with no success. Here is a code sample, parsing an XML file under linux python 2.4 (same problem with windows 2.5, tried with the first example) : #Python interpreter memory usage : 1.1 Mb private, 1.4 Mb shared #Using http://www.pixelbeat.org/scripts/ps_mem.py to get memory information
0
1436
by: chumly96 | last post by:
Hi All, I have a program with a Dbus interface, and would like to allow remote users to use telnet ( or something ) to log in, and run predefined commands against the Dbus interface, return the results, and allow the user to log off. Any examples / help would be great. Thanks
5
1433
tharden3
by: tharden3 | last post by:
I'm trying to learn the language... anyone have some code that they can post? simple code? difficult code? I just want to learn from examples. Any code that does something interesting/cool?
0
9618
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,...
1
10450
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
10153
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9245
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
7698
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
6910
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
5586
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
4375
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
2
3909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.