end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

powershellで、openldapに接続し、検索

$domain = "LDAP://ldap.mile.sexy.co.jp/ou=people,o=sexy-group"
$auth = [System.DirectoryServices.AuthenticationTypes]::FastBind
$root = New-Object System.DirectoryServices.DirectoryEntry($domain,"", "", $auth)

$query = New-Object System.DirectoryServices.DirectorySearcher($root,"(uid=end0tknr)")
$entry = $query.FindOne()
#$entries = $query.FindAll()

$entry | %{$_.Properties}
$entry.Properties.cn
$entry.Properties."cn;lang-en-phonetic"

$entry.Properties.sexysnumber

# byte列で取得されるものは、asciiへ変換
$enc = [system.Text.Encoding]::ASCII
$entry.Properties.sexysnumber | %{$enc.GetString($_)}

↑こう書くと、↓こう表示されます

PS > .\find_ldap_2.ps1

Name                        Value
----                        -----
adspath                     {LDAP://ldap.mile.sexy.co.jp/uid=end0tknr,ou=people,o=sexy-group}
ou2                         { ないしょ byte列 ...
cn;lang-en-phonetic         { ないしょ}
mobilephonenumber           { ないしょ byte列 }
sn                          { ないしょ}
sexyauthdepartment          { ないしょ byte列 }
mail                        {end0tknr@sexy.com}
givenname;lang-ja-phonetic  { ないしょ}
   :
X88882929