From: Craig R. <cra...@ep...> - 2002-08-14 06:24:06
|
Net::LDAP experts, I have a problem that has been bugging me for ages. I am trying to see if an email address exists within our organization. The = following is a snippet of code which returns the DN of an entry which match= es a certain email address: use Net::LDAP; $ldap =3D Net::LDAP->new("bartfarst.env.qld.gov.au") or die "$@"; $DS_mesg =3D $ldap->search(base =3D> "o=3Denv,st=3Dqld,c=3Dau",filter =3D> = "mail=3Dcraig.robinson\@epa.qld.gov.au"); $DS_entry =3D $DS_mesg->shift_entry; $DS_dn =3D $DS_entry->dn; print "DN: $DS_dn\n"; $ldap->unbind; It works great if the email address exists. BUT if the email address does n= ot exist, I get the following error message: "Can't call method "dn" on an undefined value at test.pl line 5." I would prefer a message like: "Sorry Craig, there is no entry which has this email address" Does anyone know of a <simple> way of finding out if an entry containing a = specific attribute exists, or better still, DOES NOT EXIST?? (If you would like to reply off-list, I will summarise and post summary bac= k to list.) Cheers, Craig Craig Robinson Environmental Protection Agency Tel: (07) 3006 4629 Fax: (07) 3247 6534 Email: cra...@ep... Visit us at: http://www.epa.qld.gov.au |