Hi
I'm not a programmer but am muddling through as best I can. I am trying to set up a PostSearchHook for Radiator (RADIUS server), that carries out an LDAP lookup, and, based on the
string returned ("staff" or "student") in the "businessCategory" attribute, will set the $role to be either 40 or 20 (a VLAN ID).
There can however be multiple attributes for "businessCategory" (I for example, have "staff" and "imageportaladmin"), but the only string values needed are "staff" or "student", a
nd if both are returned, then "staff" must take precedent.
The code I have so far:
#!/usr/bin/perl -w
use diagnostics;
use Net::LDAP;
my $role = "";
$ldap = Net::LDAP->new("ldap://ldaphost");
$ldap->bind();
$mesg = $ldap->search(base => "ou=people,dc=base",
scope => "1",
filter => "(uid=MLott)",
attrs => ['businessCategory'],
);
# unbind from LDAP cleanly
$mesg = $ldap->unbind();
What I'm not clear on is how I retrieve the data in the $mesg object. If I add the following code above the unbind() method:
foreach $entry (@entries) {
$entry->dump;
}
I get:
------------------------------------------------------------------------
dn:uid=MLott,ou=People,dc=base
businessCategory: staff
imageportaladmin
However, I need to be able to query this data for the correct strings (that I mentioned earlier). I know that dump() is method of Net::LDAP, but it shows that the query result is
correct.
If I add the following lines so that I can get a count, I only get the result of "1":
foreach $max ($mesg->count) {
print "Count = $max\n";
}
Is that because it is "1" object returned (as opposed to items in a scalar list)?
Any help would be great.
Thanks,
Mike