473,804 Members | 3,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 - SimpleLDAPObjec t.set_option ((17,
3),{})
CN=江,OU=2134, DC=localhost,DC =com
{'accountExpire s': ['92233720368547 75807'],
'badPasswordTim e': ['12856601467234 3750'],
'badPwdCount': ['0'],
'cn': ['\xe6\xb1\x9f\x e6\x9f\x8f\xe5\ xa3\x95'],
'codePage': ['0'],
'company': ['\xe8\x8f\xaf\x e8\x81\xaf\xe7\ x94\x9f
\xe7\x89\xa9\xe 7\xa7\x91\xe6\x 8a\x80'],
'countryCode': ['0'],
'department': ['\xe7\x94\x9f\x e7\x89\xa9\xe7\ xa7\x91\xe6\x8a
\x80\xe8\x99\x9 5'],
'displayName': ['\xe6\xb1\x9f\x e6\x9f\x8f\xe5\ xa3\x95'],
'distinguishedN ame': ['CN=\xe6\xb1\x9 f\xe6\x9f\x8f
\xe5\xa3\x95,OU =300\xe7\xa7\x9 1\xe6\x8a
\x80\xe8\x99\x9 5,DC=localhost, DC=com'],
'givenName': ['\xe6\x9f\x8f\x e5\xa3\x95'],
'homeMDB': ['CN=\xe4\xbf\xa 1\xe7\xae\xb1\x e5\x84\xb2\xe5\ xad
\x98\xe5\x8d\x8 0 (MAIL),CN=\xe9\ xa0\x90\xe8\xa8 \xad\xe5\x84\xb 2\xe5\xad
\x98\xe7\xbe\xa 4\xe7\xb5\x84,C N=InformationSt ore,CN=MAIL,CN= Servers,CN=
\xe9\xa0\x90\xe 8\xa8\xad\xe7\x b3\xbb\xe7\xb5\ xb1\xe7\xae
\xa1\xe7\x90\x8 6\xe7\xbe\xa4\x e7\xb5\x84,CN=A dministrative
Groups,CN=local host,CN=Microso ft
Exchange,CN=Ser vices,CN=Config uration,DC=loca lhost,DC=com'],
'homeMTA': ['CN=Microsoft MTA,CN=MAIL,CN= Servers,CN=
\xe9\xa0\x90\xe 8\xa8\xad\xe7\x b3\xbb\xe7\xb5\ xb1\xe7\xae
\xa1\xe7\x90\x8 6\xe7\xbe\xa4\x e7\xb5\x84,CN=A dministrative
Groups,CN=local host,CN=Microso ft
Exchange,CN=Ser vices,CN=Config uration,DC=loca lhost,DC=com'],
'instanceType': ['4'],
'lastLogoff': ['0'],
'lastLogon': ['12859896506671 8750'],
'legacyExchange DN': ['/o=localhost/ou=ExchangAdmin/cn=Recipients/
cn=joechiang'],
'logonCount': ['33'],
'mDBUseDefaults ': ['TRUE'],
'mail': ['j********@loca lhost.com'],
'mailNickname': ['joechiang'],
'memberOf': ['CN=AllHQStaff, CN=Users,DC=loc alhost,DC=com'],
'msExchALObject Version': ['60'],
'msExchHomeServ erName': ['/o=localhost/ou=ExchangAdmin/
cn=Configuratio n/cn=Servers/cn=MAIL'],
'msExchMailboxG uid': ['2\x04\x116^\xf c%J\x87yi\xbdj^ \x1bl'],
'msExchMailboxS ecurityDescript or': ['\x01\x00\x04\x 80x
\x00\x00\x00\x9 4\x00\x00\x00\x 00\x00\x00\x00\ x14\x00\x00\x00 \x04\x00d
\x00\x01\x00\x0 0\x00\x00\x02\x 14\x00\x03\x00\ x02\x00\x01\x01 \x00\x00\x00\x0 0\x00\x05\n
\x00\x00\x00a\x 00n\x00x\x00/\x00C\x00N\x00= \x00C\x00o\x00n \x00f\x00i
\x00g\x00u\x00r \x00a\x00t\x00i \x00o\x00n
\x00\x00\x00\x0 0\x00\x00\x00\x 00\x00\x00\x00\ x00\x00\x00\x00 \x00\x00\x00\x0 0\x00\x00\x00\x 00\x00\x00\x00\ x00\x00\x00\x00 \x00\x00\x00\x0 1\x05\x00\x00\x 00\x00\x00\x05\ x15\x00\x00\x00 \xd6\xb2i
\x1a^\xa7P\xcb\ xday
\x88\xa9\xf4\x0 1\x00\x00\x01\x 05\x00\x00\x00\ x00\x00\x05\x15 \x00\x00\x00\xd 6\xb2i
\x1a^\xa7P\xcb\ xday\x88\xa9\xf 4\x01\x00\x00'],
'msExchPolicies Included': ['{C96E41C5-C5D5-411B-8672-1A3B6602437F},
{3B6813EC-CE89-42BA-9442-D87D4AA30DBC}',
'{C96E41C5-C5D5-411B-8672-1A3B6602437F},
{26491CFC-9E50-4857-861B-0CB8DF22B5D7}'],
'msExchUserAcco untControl': ['0'],
'name': ['\xe6\xb1\x9f\x e6\x9f\x8f\xe5\ xa3\x95'],
'objectCategory ':
['CN=Person,CN=S chema,CN=Config uration,DC=loca lhost,DC=com'],
'objectClass': ['top', 'person', 'organizational Person', 'user'],
'objectGUID': ['\x13\xfa\xc2\x bb\x9e\xee|C\x9 d\xa8_\xea]\xef
\xc6\x90'],
'objectSid':
['\x01\x05\x00\x 00\x00\x00\x00\ x05\x15\x00\x00 \x00\xd6\xb2i\x 1a^\xa7P
\xcb\xday\x88\x a9u\x0c\x00\x00 '],
'primaryGroupID ': ['513'],
'proxyAddresses ':
['X400:c=TW;a= ;p=localhost;o= Exchange;s=joec hiang;',
'SMTP:jo******* @localhost.com'],
'pwdLastSet': ['12858767039656 2500'],
'sAMAccountName ': ['joechiang'],
'sAMAccountType ': ['805306368'],
'showInAddressB ook': ['CN=\xe5\x85\xa 8\xe5\x9f\x9f\x e9\x80\x9a
\xe8\xa8\x8a\xe 6\xb8\x85\xe5\x 96\xae,CN=All Global Address
Lists,CN=Addres s Lists Container,CN=lo calhost,CN=Micr osoft
Exchange,CN=Ser vices,CN=Config uration,DC=loca lhost,DC=com',
'CN=\xe7\x87\x9 f\xe9\x81\x8b\x e8\x99\x95,CN=A ll
Address Lists,CN=Addres s Lists Container,CN=lo calhost,CN=Micr osoft
Exchange,CN=Ser vices,CN=Config uration,DC=loca lhost,DC=com',
'CN=\xe7\x94\x9 f\xe7\x89\xa9\x e7\xa7\x91\xe6\ x8a
\x80\xe8\x99\x9 5,CN=All Address Lists,CN=Addres s Lists
Container,CN=lo calhost,CN=Micr osoft
Exchange,CN=Ser vices,CN=Config uration,DC=loca lhost,DC=com',
'CN=\xe6\x89\x8 0\xe6\x9c\x89\x e4\xbd\xbf
\xe7\x94\xa8\xe 8\x80\x85,CN=Al l Address Lists,CN=Addres s Lists
Container,CN=lo calhost,CN=Micr osoft
Exchange,CN=Ser vices,CN=Config uration,DC=loca lhost,DC=com'],
'sn': ['\xe6\xb1\x9f'],
'textEncodedORA ddress':
['c=TW;a= ;p=localhost;o= Exchange;s=joec hiang;'],
'uSNChanged': ['22943844'],
'uSNCreated': ['21991450'],
'userAccountCon trol': ['66048'],
'userPrincipalN ame': ['j**@localhost. com'],
'whenChanged': ['20080624074423 .0Z'],
'whenCreated': ['20071205035154 .0Z']}
None
Jul 8 '08 #1
2 5571
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\x e6\x9f\x8f\xe5\ xa3\x95'],
>>unicode('\xe6 \xb1\x9f\xe6\x9 f\x8f\xe5\xa3\x 95','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\x e6\x9f\x8f\xe5\ xa3\x95'],
>>unicode('\xe6 \xb1\x9f\xe6\x9 f\x8f\xe5\xa3\x 95','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
5530
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 working, however, when the list of users is shown in the output, it seems to display the users in the order their accounts were created, with Administrator obviously being first. What do you think would be the best way to get the list to be sorted by...
0
4190
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 anybody give me any information about this kind of conflict ?
10
4070
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 Pop up windows Authentication box so that user will give his userId, Password & domain name for authenticaion. After that I want to take these three info of user and make a search in Active Directory.
0
2036
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: LDAP://OU=BE,OU=SE,DC=eu,DC=aagp,DC=corp. This works fine. My computer is in and OU under the BE folder, and so is my User. I have no problems connecting to the Active Directory. But now that my code is finished i want to put it online on one of the company servers. but when i...
3
7490
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 on her local machine. Everything looks pretty good. OpenLDAP/cygwin works great. PostgreSQL works great. Apache runs. PHP runs. But when I try to connect to my PostgreSQL server using PHPPgAdmin, I
2
5991
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 use the System.DirectoryServices.ActiveDirectory namespace. I don't even know if this is the right way to go as I can't seem to find anything in that namespace that would help me query active directory for names. I can't use an LDAP query...
0
2512
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 created they can tell me who they want their account to be modeled after. The html app works great as a .hta file but when it is saved as a web page it won't list the members of any groups. I get an error on line 182: "ActiveX component can't create...
1
15221
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 can no longer connect to the domain controller. Ping resolves the domain controllers name to the correct ip nslookup finds the ip but can not resolve the name. When I attempt to log on to a machine on the domain it takes around twenty minutes...
0
13851
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 LDAP connector for MySQL Community to connect to Active Directory. Alas, nothing. So I figured I'd try doing something similar. My business problem is/was as follows: I use Active Directory on Windows Server 2003 to manage my small corporate...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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
10330
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
10319
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
9144
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...
0
5520
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...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4297
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
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.