#!/usr/bin/tclsh
#
# search default host and base for full names containing each of the command
# line arguments
#

if ![llength $argv] {
    puts "Nothing to search for - exiting"
}


set maxresults 5
set returnattribs [list cn sn o ou mail telephoneNumber postalAddress title]

package require Ldap

LdapInit

set Conn [LdapBind $ldap(host) $ldap(port) $ldap(binddn,search) {}]

foreach a $argv {
    set ret [LdapSearch $Conn sub {} $ldap(searchbase) $maxresults \
		 cn=*$a* $returnattribs]
    foreach r $ret {
	puts $r
    }
}

LdapUnBind $Conn

#

