[Haskell-cafe] LDAP hackage problem.

Magicloud Magiclouds magicloud.magiclouds at gmail.com
Fri Jan 13 04:08:05 CET 2012


Hi,
  I have a Windows AD server. And ldapsearch tool works to get
someone's information. But when I turned it into Haskell code. It does
not work as expected.
  Here is the ldapsearch and result. You can see that sn/givenName
have values that are encoded utf-8.
  Next to it is the code I am using. Running this code returns the
similar thing. The problem is that only sn/givenName/displayName are
empty. I have tried a few diag ways trying to find out why. No luck.

$ ldapsearch -h vancloa.cn -D
CN=wangshida.admin,OU=admin_accounts,DC=vancloa,DC=cn -w ******** -b
"DC=vancloa,DC=cn" -x
'(&(sAMAccountName=chengtao)(&(objectClass=user)(!(ou=Recycle_Bin))))'
# extended LDIF
#
# LDAPv3
# base <DC=vancloa,DC=cn> with scope subtree
# filter: (&(sAMAccountName=chengtao)(&(objectClass=user)(!(ou=Recycle_Bin))))
# requesting: ALL
#

# 0000000634, Employees_Accounts, vancloa.cn
dn: CN=0000000634,OU=Employees_Accounts,DC=vancloa,DC=cn
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: user
cn: 0000000634
sn:: 56iL
c: CN
title:: 5oqA5pyv5pSv5oyB5bel56iL5biI
description: 0000000634
physicalDeliveryOfficeName:: 5oiQ6YO95LuT5YKo
givenName:: 5rab
distinguishedName: CN=0000000634,OU=Employees_Accounts,DC=vancloa,DC=cn
instanceType: 4
whenCreated: 20101231073752.0Z
whenChanged: 20120106005157.0Z
displayName:: 56iL5rab

# search reference
ref: ldap://ForestDnsZones.vancloa.cn/DC=ForestDnsZones,DC=vancloa,DC=cn

# search reference
ref: ldap://DomainDnsZones.vancloa.cn/DC=DomainDnsZones,DC=vancloa,DC=cn

# search reference
ref: ldap://vancloa.cn/CN=Configuration,DC=vancloa,DC=cn

# search result
search: 2
result: 0 Success

# numResponses: 5
# numEntries: 1
# numReferences: 3

 6|main :: IO ()
 7|main = do
 8|  args <- getArgs
 9|  let alias = head args
10|  putStrLn alias
11|  entries <- failLDAP $ do
12|    ldap <- ldapOpen "vancloa.cn" 389
13|    ldapSimpleBind ldap
"CN=wangshida.admin,OU=admin_accounts,DC=vancloa,DC=cn" "********"
14|    ldapSearch ldap (Just "DC=vancloa,DC=cn") LdapScopeSubtree
(Just ("(&(sAMAccountName=" ++ alias ++
")(&(objectClass=user)(!(ou=Recycle_Bin))))"\
   )) LDAPAllUserAttrs False --(LDAPAttrList ["sn", "givenname"])
False
15|  let LDAPEntry _ attrs = head entries
16|      sn = head $ snd $ head $ filter (\(a, _) -> a == "sn") attrs
17|      givenName = head $ snd $ head $ filter (\(a, _) -> a ==
"givenName") attrs
18|  print entries

-- 
竹密岂妨流水过
山高哪阻野云飞



More information about the Haskell-Cafe mailing list