Anonymous user
Active Directory/Search for a user: Difference between revisions
Active Directory/Search for a user (view source)
Revision as of 04:36, 3 October 2012
, 11 years agomove UNIX Shell to correct position
(Add UNIX Shell implementation) |
m (move UNIX Shell to correct position) |
||
Line 533:
5 File(s) 748,993,785 bytes
7 Dir(s) 952,183,820,288 bytes free</pre>
=={{header|Tcl}}==▼
One can do it with the low level [[Connect to Active Directory]] based handle with this code:▼
This is just the basic setup.▼
<lang tcl>set Username "TestUser"▼
set Filter "((&objectClass=*)(sAMAccountName=$Username))"▼
set Base "dc=skycityauckland,dc=sceg,dc=com"▼
set Attrs distinguishedName</lang>▼
Now do the actual search.▼
<lang tcl>set result [ldap::search $conn $Base $Filter $Attrs -scope subtree]</lang>▼
If we have only a single result its easy:▼
<lang tcl>if {[llength $result] == 1} {▼
puts [dict get [lindex $result 0 1] distinguishedName]▼
}</lang>▼
Looping over the result set to output some values.▼
<lang tcl>foreach pair $result {▼
lassign $pair cn attributes▼
puts [dict get $attributes distinguishedName]▼
}</lang>▼
If you're bored you can also use this instead:▼
<lang tcl>package require ldapx▼
set conn [ldapx::connect $BindDN $Password]▼
$conn traverse $Base $Filter $Attrs e {▼
puts [$e get distinguishedName]▼
}</lang>▼
=={{header|UNIX Shell}}==
Line 572 ⟶ 602:
</pre>
▲=={{header|Tcl}}==
▲One can do it with the low level [[Connect to Active Directory]] based handle with this code:
▲This is just the basic setup.
▲<lang tcl>set Username "TestUser"
▲set Filter "((&objectClass=*)(sAMAccountName=$Username))"
▲set Base "dc=skycityauckland,dc=sceg,dc=com"
▲set Attrs distinguishedName</lang>
▲Now do the actual search.
▲<lang tcl>set result [ldap::search $conn $Base $Filter $Attrs -scope subtree]</lang>
▲If we have only a single result its easy:
▲<lang tcl>if {[llength $result] == 1} {
▲ puts [dict get [lindex $result 0 1] distinguishedName]
▲}</lang>
▲Looping over the result set to output some values.
▲<lang tcl>foreach pair $result {
▲ lassign $pair cn attributes
▲ puts [dict get $attributes distinguishedName]
▲}</lang>
▲If you're bored you can also use this instead:
▲<lang tcl>package require ldapx
▲set conn [ldapx::connect $BindDN $Password]
▲$conn traverse $Base $Filter $Attrs e {
▲ puts [$e get distinguishedName]
▲}</lang>
=={{header|VBScript}}==
|