473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

windows active directory ldap output encoding

Hi..
Im trying to get some information out of a windows sever 2003 chinese
active directory system
so let's say encoding is probably big5 or utf-8

what im doing is simliar to ldapsearch in shell with my python script
using python ldap module

the result is not the correct encoding..

i've look many places and tried many different encoding on the top of
the script #coding=big5 etc..

below is the wrong encoding output .. any help will be much
appreciated..

*** ldap://2134.localhost.com:389 - SimpleLDAPObject.set_option ((17,
3),{})
CN=江,OU=2134,DC=localhost,DC=com
{'accountExpires': ['9223372036854775807'],
'badPasswordTime': ['128566014672343750'],
'badPwdCount': ['0'],
'cn': ['\xe6\xb1\x9f\xe6\x9f\x8f\xe5\xa3\x95'],
'codePage': ['0'],
'company': ['\xe8\x8f\xaf\xe8\x81\xaf\xe7\x94\x9f
\xe7\x89\xa9\xe7\xa7\x91\xe6\x8a\x80'],
'countryCode': ['0'],
'department': ['\xe7\x94\x9f\xe7\x89\xa9\xe7\xa7\x91\xe6\x8a
\x80\xe8\x99\x95'],
'displayName': ['\xe6\xb1\x9f\xe6\x9f\x8f\xe5\xa3\x95'],
'distinguishedName': ['CN=\xe6\xb1\x9f\xe6\x9f\x8f
\xe5\xa3\x95,OU=300\xe7\xa7\x91\xe6\x8a
\x80\xe8\x99\x95,DC=localhost,DC=com'],
'givenName': ['\xe6\x9f\x8f\xe5\xa3\x95'],
'homeMDB': ['CN=\xe4\xbf\xa1\xe7\xae\xb1\xe5\x84\xb2\xe5\xad
\x98\xe5\x8d\x80 (MAIL),CN=\xe9\xa0\x90\xe8\xa8\xad\xe5\x84\xb2\xe5 \xad
\x98\xe7\xbe\xa4\xe7\xb5\x84,CN=InformationStore,C N=MAIL,CN=Servers,CN=
\xe9\xa0\x90\xe8\xa8\xad\xe7\xb3\xbb\xe7\xb5\xb1\x e7\xae
\xa1\xe7\x90\x86\xe7\xbe\xa4\xe7\xb5\x84,CN=Admini strative
Groups,CN=localhost,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=localhost ,DC=com'],
'homeMTA': ['CN=Microsoft MTA,CN=MAIL,CN=Servers,CN=
\xe9\xa0\x90\xe8\xa8\xad\xe7\xb3\xbb\xe7\xb5\xb1\x e7\xae
\xa1\xe7\x90\x86\xe7\xbe\xa4\xe7\xb5\x84,CN=Admini strative
Groups,CN=localhost,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=localhost ,DC=com'],
'instanceType': ['4'],
'lastLogoff': ['0'],
'lastLogon': ['128598965066718750'],
'legacyExchangeDN': ['/o=localhost/ou=ExchangAdmin/cn=Recipients/
cn=joechiang'],
'logonCount': ['33'],
'mDBUseDefaults': ['TRUE'],
'mail': ['j********@localhost.com'],
'mailNickname': ['joechiang'],
'memberOf': ['CN=AllHQStaff,CN=Users,DC=localhost,DC=com'],
'msExchALObjectVersion': ['60'],
'msExchHomeServerName': ['/o=localhost/ou=ExchangAdmin/
cn=Configuration/cn=Servers/cn=MAIL'],
'msExchMailboxGuid': ['2\x04\x116^\xfc%J\x87yi\xbdj^\x1bl'],
'msExchMailboxSecurityDescriptor': ['\x01\x00\x04\x80x
\x00\x00\x00\x94\x00\x00\x00\x00\x00\x00\x00\x14\x 00\x00\x00\x04\x00d
\x00\x01\x00\x00\x00\x00\x02\x14\x00\x03\x00\x02\x 00\x01\x01\x00\x00\x00\x00\x00\x05\n
\x00\x00\x00a\x00n\x00x\x00/\x00C\x00N\x00=\x00C\x00o\x00n\x00f\x00i
\x00g\x00u\x00r\x00a\x00t\x00i\x00o\x00n
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x 00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x01\x05\x00\x00\x 00\x00\x00\x05\x15\x00\x00\x00\xd6\xb2i
\x1a^\xa7P\xcb\xday
\x88\xa9\xf4\x01\x00\x00\x01\x05\x00\x00\x00\x00\x 00\x05\x15\x00\x00\x00\xd6\xb2i
\x1a^\xa7P\xcb\xday\x88\xa9\xf4\x01\x00\x00'],
'msExchPoliciesIncluded': ['{C96E41C5-C5D5-411B-8672-1A3B6602437F},
{3B6813EC-CE89-42BA-9442-D87D4AA30DBC}',
'{C96E41C5-C5D5-411B-8672-1A3B6602437F},
{26491CFC-9E50-4857-861B-0CB8DF22B5D7}'],
'msExchUserAccountControl': ['0'],
'name': ['\xe6\xb1\x9f\xe6\x9f\x8f\xe5\xa3\x95'],
'objectCategory':
['CN=Person,CN=Schema,CN=Configuration,DC=localhost ,DC=com'],
'objectClass': ['top', 'person', 'organizationalPerson', 'user'],
'objectGUID': ['\x13\xfa\xc2\xbb\x9e\xee|C\x9d\xa8_\xea]\xef
\xc6\x90'],
'objectSid':
['\x01\x05\x00\x00\x00\x00\x00\x05\x15\x00\x00\x00\ xd6\xb2i\x1a^\xa7P
\xcb\xday\x88\xa9u\x0c\x00\x00'],
'primaryGroupID': ['513'],
'proxyAddresses':
['X400:c=TW;a= ;p=localhost;o=Exchange;s=joechiang;',
'SMTP:jo*******@localhost.com'],
'pwdLastSet': ['128587670396562500'],
'sAMAccountName': ['joechiang'],
'sAMAccountType': ['805306368'],
'showInAddressBook': ['CN=\xe5\x85\xa8\xe5\x9f\x9f\xe9\x80\x9a
\xe8\xa8\x8a\xe6\xb8\x85\xe5\x96\xae,CN=All Global Address
Lists,CN=Address Lists Container,CN=localhost,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=localhost ,DC=com',
'CN=\xe7\x87\x9f\xe9\x81\x8b\xe8\x99\x95,CN=All
Address Lists,CN=Address Lists Container,CN=localhost,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=localhost ,DC=com',
'CN=\xe7\x94\x9f\xe7\x89\xa9\xe7\xa7\x91\xe6\x8a
\x80\xe8\x99\x95,CN=All Address Lists,CN=Address Lists
Container,CN=localhost,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=localhost ,DC=com',
'CN=\xe6\x89\x80\xe6\x9c\x89\xe4\xbd\xbf
\xe7\x94\xa8\xe8\x80\x85,CN=All Address Lists,CN=Address Lists
Container,CN=localhost,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=localhost ,DC=com'],
'sn': ['\xe6\xb1\x9f'],
'textEncodedORAddress':
['c=TW;a= ;p=localhost;o=Exchange;s=joechiang;'],
'uSNChanged': ['22943844'],
'uSNCreated': ['21991450'],
'userAccountControl': ['66048'],
'userPrincipalName': ['j**@localhost.com'],
'whenChanged': ['20080624074423.0Z'],
'whenCreated': ['20071205035154.0Z']}
None
Jul 8 '08 #1
2 5486
jo3c wrote:
Im trying to get some information out of a windows sever 2003 chinese
active directory system
so let's say encoding is probably big5 or utf-8
The Unicode encoding of LDAP attributes with syntax Directory String is
always UTF-8 (e.g. attributes 'cn', 'sn', 'givenName' or 'displayName').
what im doing is simliar to ldapsearch in shell with my python script
using python ldap module

the result is not the correct encoding..
What exactly did you expect?
'cn': ['\xe6\xb1\x9f\xe6\x9f\x8f\xe5\xa3\x95'],
>>unicode('\xe6\xb1\x9f\xe6\x9f\x8f\xe5\xa3\x95',' utf-8')
u'\u6c5f\u67cf\u58d5'

I cannot tell whether this Unicode string of length 3 is correct since I
cannot read Chinese and I probably don't have the necessary fonts
installed. At least it decodes as UTF-8 which is correct at the LDAP level.
'displayName': ['\xe6\xb1\x9f\xe6\x9f\x8f\xe5\xa3\x95'],
>>unicode('\xe6\xb1\x9f\xe6\x9f\x8f\xe5\xa3\x95',' utf-8')
u'\u6c5f\u67cf\u58d5'

Maybe you should provide the original Unicode string (e.g. in Python
syntax) and tell us how you store that into your AD server. Note that
the tools used to maintain AD are also part of the game.

Ciao, Michael.
Jul 8 '08 #2
Michael Ströder wrote:
jo3c wrote:
>Im trying to get some information out of a windows sever 2003 chinese
active directory system
so let's say encoding is probably big5 or utf-8

The Unicode encoding of LDAP attributes with syntax Directory String is
always UTF-8 (e.g. attributes 'cn', 'sn', 'givenName' or 'displayName').
BTW: I'd be curious to see whether my web2ldap works with Chinese
characters. Since you already have python-ldap installed it's easy to
download (from http://www.web2ldap.de/download.html) and unpack the
tar.gz and start it as stand-alone web server:

python <web2ldap-dir>/sbin/web2ldap.py -d off

Ah forgot, pyweblib needs to also be installed with usual
python setup.py install:
http://www.stroeder.com/pylib/PyWebLib/

If everything is correctly configured in your browser you should the
correct Unicode chars. Maybe you can even maintain your AD entries.

Ciao, Michael.
Jul 8 '08 #3

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

Similar topics

2
by: Victor Lokhmatov | last post by:
Hello Everyone, My company has asked me to put a company directory on our intranet site and I'm trying to use php to extract the users from our active directory server. I've got everything...
0
by: Lorenzo | last post by:
I'm trying to access to a LDAP server by a VB 6 application in order to get info about user. The following code works fine running on Windows 2000 professional but fails on Windows XP. Can...
10
by: Hriday | last post by:
Hi there, Please help me..It is urgent This is Hriday, working on windows authentication with Active Directory... My requirment is when a user sends a request to my web Applicatoin I want to...
0
by: RTT | last post by:
here is my current situation. I develop a program on my computer's localhost. From there i contact Active directory succesfull using a connectionstring like:...
3
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work...
2
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could...
0
by: bcanter | last post by:
I found a file on the web that will allow you to enumerate groups but it was an .hta and the top level admins won't allow this. I need to give managers access to the groups so that when a new user is...
1
by: eblackmo | last post by:
I have a test network consisting of four servers running windows 2003 server R2 SP2. I have set up a domain which functioned correctly for about a day and a half until the other servers decided they...
0
JamieHowarth0
by: JamieHowarth0 | last post by:
I have been trying to find a solution to this on the Internet for months. Literally, ages and ages and ages, praying that someone in the open-source community has enough knowledge to put together an...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.