Topic
1 reply Latest Post - ‏2013-05-01T15:32:19Z by sandzb
Rational_APAC
Rational_APAC
1 Post
ACCEPTED ANSWER

Pinned topic How to access to RDS (Ldap Server) via perl - script sample

‏2012-07-20T07:26:44Z |
My client was working on modifying some RDS data via Perl script and I would love to share this since it quite useful.



#!/usr/bin/perl

use Net::LDAP;
use strict;

  1. Create LDAP Object
my $port=1389;
my $ldap_serv="ldapserver.com";
my $ldap = Net::LDAP->new($ldap_serv,port=>$port);

  1. Login to LDAP Server
my $mesg = $ldap->bind;
if( $mesg->code == 0 ){
print "bind success\n";
}
else {
warn "bind fail: ". $mesg->error;
exit( $mesg->error );
}

my $searchResult = $ldap->search( base => 'ou=people,
dc=telelogic,dc=com', filter => "uid=firstname.lastname.com" );
foreach my $entry ( $searchResult->entries ) {
$entry->dump
}
  1. Logout
$ldap->unbind;

#-------------------------------------------------------------
  • sandzb
    sandzb
    1 Post
    ACCEPTED ANSWER

    Re: How to access to RDS (Ldap Server) via perl - script sample

    ‏2013-05-01T15:32:19Z  in response to Rational_APAC

    But how is the customer using tdsadmin (LDAP admin account) to add/modify users within RDS?  I know that RDS has encrypted this password.  I can't seem to find a way to use it to authenticate into LDAP RDS.

     

       # use for changes/edits
       my $userToAuthenticate="tdsadmin";
       my $passwdToAuthenticate="encrypted password";
       print "My authentication: $userToAuthenticate and $passwdToAuthenticate";
       my $mesg = $ldap->bind ( 'cn=$userToAuthenticate, ou=people,dc=telogic,dc-com',
                                password => '$passwdToAuthenticate');
     

    Sandy