Re: Handling output from ldapsearch



On Mon, 30 Jun 2008 06:38:57 -0700 (PDT), utbloke@xxxxxxxxx wrote:

"dn: CN=user01,CN=Users,DC=mynet,DC=local
sAMAccountName: user01

dn: CN=user02,CN=Users,DC=mynet,DC=local
sAMAccountName: user02

dn: CN=user03,CN=Users,DC=mynet,DC=local
sAMAccountName: user03"

Hi,
assuming that each result is on a line of its own and that the whole
string is in a variable 's' e.g. by means of a call like
set s [<your call here>]
the following should work:
---
# turn 's' into a list of lines
set lineLst [split $s \n]

# make sure you start with an empty list
set userLst {}

# iterate over the lines
foreach line $lineLst {
if { $line eq "" } {
# ignore empty lines
continue
}
# isolate the words in $line
set wordLst [split $line " "]
# ... and take the last one
lappend userLst [lindex $wordLst end]
}
puts "userLst: $userLst"
---
HTH
Helmut Giese
.



Relevant Pages

  • Re: Handling output from ldapsearch
    ... sAMAccountName: user01 ... sAMAccountName: user02 ... sAMAccountName: user03" ... lappend userLst ...
    (comp.lang.tcl)
  • Re: LDAP Search Query Question
    ... The query/filter/search string is ... assuming that %login% and samaccountname are the same thing in your ... Active Directory uses cn as the RDN, ...
    (microsoft.public.windows.server.active_directory)
  • Re: Home Drive mapping problem
    ... As you're using VBScript, perhaps you shouldn't place %username% in there. ... place the user's sAMAccountName in the string. ...
    (microsoft.public.windows.server.active_directory)