searching ldap by guid/uid

2007-08-30 Thread fintan
Hi I'm trying to search eDirectory by the guid/uid. My query would look
something like this.

(&(!(loginDisabled=True))(!(givenname=System))(|(guid=809c175abd1eda11bb4c003005470881)))

When I try to decode the guid/uid into hex. I get a type error.

   ldap_result_id = l.search(searchBase, searchScope, searchFilter,
retrieveAttributes)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 478, in
search
return self.search_ext
(base,scope,filterstr,attrlist,attrsonly,None,None)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 470, in
search_ext
timeout,sizelimit,
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 94, in
_ldap_call
result = func(*args,**kwargs)
TypeError: argument 3 must be string without null bytes, not str

I was wondering is it possible to search by a hex value? Thanks

   fintan.
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev


Re: KeyError while performing 'ldapsearch' operation and processing the result data

2009-10-18 Thread Fintan MacMahon
Hi Guruprasad

Had the same issue and someone was kind enough to point me in the right 
direction. Here's what I was told

"A uid has to be changed into a legible format Chapter 3 of RFC 4515 (LDAPv3 
filter strings) starts with:

The string representation of an LDAP search filter is a string of UTF-8 
[RFC3629] encoded Unicode characters [Unicode] [..]

So please have a look at RFC 4515 to find out how to escape hex values in a 
search filter.

Function ldap.filter.escape_filter_chars() is helpful for that."

Thanks

  fintan


On Sunday 20 September 2009 15:02:14 Guruprasad wrote:
> Hi,
> I have been trying to write a function to search a LDAP directory by
> using the python-ldap APIs.
> Here is the code I have written:
> 
> 
> def getNextUid():
> uidList=[]
> try:
> l=ldap.initialize(ldap_host)
> l.bind_s(ldap_admin_dn,ldap_admin_pass)
>
>  ldap_result=l.search(ldap_base_dn,ldap.SCOPE_SUBTREE,'cn=*',['uidNumber'])
>  while 1:
> result_type, result_data=l.result(ldap_result,0)
> if (result_data == []):
> break
> a=result_data[0][1]['uidNumber']
> print a
> except ldap.SERVER_DOWN:
> print "LDAP server down"
> 
> 
> What I am trying to do in this piece of code is get the list of the
> values of 'uidNumber' attribute. The search operation returns a list
> containing a tuple. The tuple contains the DN as one value and a
> dictionary with uidNumber and its value. I am trying to extract the
> value of the uidNumber. I found that result_data was a dictionary
> having a key 'uidNumber', but when I try to print its value, I get a
> KeyError. Strangely, when I print result_data.keys(), 'uidNumber' is
> present.
> 
> 
> Thank you.
> 
> Regards,
> Guruprasad.
> 
> ---
> --- Come build with us! The BlackBerry® Developer Conference in SF, CA
>  is the only developer event you need to attend this year. Jumpstart your
>  developing skills, take BlackBerry mobile applications to market and stay
>  ahead of the curve. Join us from November 9-12, 2009. Register
>  now! http://p.sf.net/sfu/devconf
> ___
> Python-LDAP-dev mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
> 

--
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Python-LDAP-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev