Below is a ldap search sub routine that I am using inside of a webform. What I am trying to do is have this program search either by account number or user name depending on what the end user choices on the form and if it finds user results to either return a 0 or a 1 and thus by this output continue with other routines. Do I have my filter variables correct? What am I missing here?
$type either equals cn or uid $search_str is users input either a name (ie dilbert or account number 012101) Please note that while a user simply puts in a # the cn actually looks something like this is abc-012101 or def-012601 so I want the letters before the - to be wild carded. If anyone can help or give me some ideas to an alternative search I'd appreciate it. Thanks, sub ldapsearch { $ldap_con = new Net::LDAPapi($ldap_host); if ($ldap_con == -1) { "Unable to Open LDAP Connection to $ldap_host"; } $status = $ldap_con->bind_s("cn=Directory Manager", $ldap_password); @attrs = (); if ($choice eq "uid") { $filter = "$type=$search_str"; $status = $ldap_con->search_s($ldap_dn,LDAP_SCOPE_SUBTREE,$filter,\@attrs,0); if ($status != LDAP_SUCCESS) { $ldap_con->errstring; } %ldap_exists = %{$ldap_con->get_all_entries}; foreach $result (keys %ldap_exists) { $value = "@{$ldap_exists{$result}{uid}}"; } if ($value eq $search_str) { return 1; } return(0); } else { $filter = "$type=*-$search_str"; $status = $ldap_con->search_s($ldap_dn,LDAP_SCOPE_SUBTREE,$filter,\@attrs,0); if ($status != LDAP_SUCCESS) { $ldap_con->errstring; } %ldap_exists = %{$ldap_con->get_all_entries}; foreach $result (keys %ldap_exists) { $value = "@{$ldap_exists{$result}{uid}}"; } if ($value eq $search_str) { return 1; } return(0); } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]