LDAP : Binding problem

373 views
Skip to first unread message

Antony Joseph

unread,
Nov 2, 2007, 5:22:43 AM11/2/07
to turbo...@googlegroups.com
hi ,
I am new to Python Ldap programming,
I am trying to read the user details from Active directory using LDAP(python)
I am getting errors :
                     antony@DG11:~/Desktop/UploadCards$ python ldap1.py
                     successfull
                     {'info': '00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece', 'desc': 'Operations error'}

Anyone can tell me whats wrong in my code ?

[Code]

import ldap
try:
    l = ldap.open("101.1.1.2")
    l.protocol_version = ldap.VERSION3    
    username = "cn=raj,o=any.com"
    password  = "secret"
    keyword = "ldap"    
    l.simple_bind(username, password)

    print "successfull"
               
    base=""
    scope=ldap.SCOPE_SUBTREE
    filter ="cn=" + "*" + keyword + "*"
    retrieve_attributes = None
    count = 0
    result_set = []
    timeout = 0
    try:
               result_id = l.search(base, scope, filter, retrieve_attributes)
        while 1:
                                                                                                                         
                  result_type, result_data = l.result (result_id,timeout)-----------> throwing Exceptions

                   if (result_data == []):
                           break
                   else:
                           if result_type == ldap.RES_SEARCH_ENTRY:
                               result_set.append(result_data)
                    print "%d.\nName: %s\nDescription: %s\nE-mail: %s\nPhone: %s\n" % (count)
        except ldap.LDAPError , error_message:
               print error_message

except ldap.LDAPError, e:
    print e

Florent Aide

unread,
Nov 2, 2007, 12:19:58 PM11/2/07
to turbo...@googlegroups.com
On Nov 2, 2007 10:22 AM, Antony Joseph <antonyj...@gmail.com> wrote:
> hi ,
> I am new to Python Ldap programming,
> I am trying to read the user details from Active directory using

Please try to ask on the python LDAP mailing list first:
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev

they will surely have more info to give you.

But from what I see you have given wrong credential and couldn't
perform a successful bind, which is the minimum requirement to be able
to query the directory.

Regards,
Florent.

Florent Aide

unread,
Nov 2, 2007, 12:37:37 PM11/2/07
to turbo...@googlegroups.com
One more remark: avoid using html emails when posting to mailing
lists, google blocked your post because it though it was spam, and
even the notification from the server (that I usually receive each
time a mail is stored on the server for review) was flagged as spam :)

Florent.

shday

unread,
Nov 2, 2007, 8:01:11 PM11/2/07
to TurboGears
As you are using Active Directory, you may find this library easier to
use:

http://tgolden.sc.sabren.com/python/active_directory.html

If you need to stick with python-ldap then it may be easier to debug
you code using
synchronous mode:

l.simple_bind_s(username, password)

Also, try using the initialize function instead of open (open is
depreciated).

Steve

> except ldap.LDAPError, error_message:

Antony Joseph

unread,
Nov 3, 2007, 3:23:30 AM11/3/07
to turbo...@googlegroups.com
hi

I am getting some new errors ;
                      No Such Object. <32>
Server error: 0000208D: NameErr: DSID-031001A8, problem 2001 (NO_OBJECT), data 0, best match of:
    ''


Any clues ,


Antony

Antony Joseph

unread,
Nov 6, 2007, 6:15:25 AM11/6/07
to turbo...@googlegroups.com
hi
I am using active_directory
its working fine with python2.5 in windows

1.i had plugged active_directory  code in linux machine , turbogears1.0 with python 2.4

It not workings...............

errors :
                import error no module active_directory
I tried to install active_directory , it throwing exception again no modules win32api not found
then I tried to install win32api, it throwing exception again no modules _winreg not found


can you tell , how can i solve the problems

thanks
Antony



On 11/3/07, shday < stephe...@gmail.com> wrote:

Diez B. Roggisch

unread,
Nov 6, 2007, 6:25:25 AM11/6/07
to turbo...@googlegroups.com, Antony Joseph
On Tuesday 06 November 2007 12:15:25 Antony Joseph wrote:
> hi
> I am using active_directory
> its working fine with python2.5 in windows
>
> 1.i had plugged active_directory code in linux machine , turbogears1.0
> with python 2.4
>
> It not workings...............
>
> errors :
> import error no module active_directory
> I tried to install active_directory , it throwing exception again no
> modules win32api not found
> then I tried to install win32api, it throwing exception again no modules
> _winreg not found
>
>
> can you tell , how can i solve the problems

using windows as server? win32 are windows-specific modules, they don't exist
on linux.

Diez

Reply all
Reply to author
Forward
0 new messages