|
|
Line 533: |
Line 533: |
|
5 File(s) 748,993,785 bytes |
|
5 File(s) 748,993,785 bytes |
|
7 Dir(s) 952,183,820,288 bytes free</pre> |
|
7 Dir(s) 952,183,820,288 bytes free</pre> |
|
|
|
|
⚫ |
|
|
⚫ |
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] |
|
⚫ |
|
|
|
|
|
⚫ |
Looping over the result set to output some values. |
|
⚫ |
<lang tcl>foreach pair $result { |
|
⚫ |
lassign $pair cn attributes |
|
⚫ |
puts [dict get $attributes distinguishedName] |
|
⚫ |
|
|
|
|
|
⚫ |
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] |
|
⚫ |
|
|
|
|
|
|
=={{header|UNIX Shell}}== |
|
=={{header|UNIX Shell}}== |
Line 572: |
Line 602: |
|
|
|
|
|
</pre> |
|
</pre> |
|
|
|
⚫ |
|
|
⚫ |
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] |
|
⚫ |
|
|
|
|
|
⚫ |
Looping over the result set to output some values. |
|
⚫ |
<lang tcl>foreach pair $result { |
|
⚫ |
lassign $pair cn attributes |
|
⚫ |
puts [dict get $attributes distinguishedName] |
|
⚫ |
|
|
|
|
|
⚫ |
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] |
|
⚫ |
|
|
|
|
|
|
|
=={{header|VBScript}}== |
|
=={{header|VBScript}}== |