Hi all, I am trying to delete entries from an LDAP server and I don't understand why my code is not deleting the relevant entries. Using an ldap browser the top level directory has the following next to it: dc=test_ldap_server, dc=com

There are four subdirectories within this directory:

cn=Manager
ou=admin
ou=list1
ou=list2

The users I want to delete are in the buyers and suppliers directories and each have nodes:

uid = username1
uid = username2
.......
uid = username100


How come my script doesn't actually delete the users? It is connecting to the correct server. I think the problem is perhaps something to do with the ldap dir structure - perhaps.


here is my code:
#############################################################
#!/usr/bin/perl
use Net::LDAP;
use strict;
use lib ('/app/tracker/perl');
use MDR::Password;
use CGI;
use DBI;

$ENV{'NLS_LANG'}="ENGLISH_UNITED KINGDOM.WE8ISO8859P1";
$ENV{'ORACLE_HOME'}="/home/oracle/OraHome1";

use BIP::SSO;
my $conf = BIP::SSO->new();
my $cf = $conf->{_cfg};

my $ldap = Net::LDAP->new($cf->{'ldap_host'});
$ldap->bind("cn=Manager,dc=test_ldap_server,dc=com", $cf->{'ldap_passwd'});
   $ldap->bind (   # bind to a directory with dn and password
       dn       => 'cn=Manager,dc=test_ldap_server,dc=com',
       password => $cf->{'ldap_passwd'}
   );
while(<>) {
       chomp $_;
       print "username: $_ \n";
       if($_ eq 'test_user1'){
       my $dn="uid=$_,ou=Manager,dc=test_ldap_server,dc=com";
       eval{$ldap->delete($dn)};
       if($@){
           print "error:  $@ \n";
       }else{
           print "username $_ deleted \n";
       }
       exit;
       }
}
#############################################################


Any ideas ?


Cheers,

Graeme :)



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to