2 ################################################################################
4 # File: $RCSfile: LDAP.pm,v $
5 # Revision: $Revision: 1.3 $
6 # Description: The Clearquest LDAP Perl Module.
7 # Author: Andrew@ClearSCM.com
8 # Created: Fri Sep 22 09:21:18 CDT 2006
9 # Modified: $Date: 2011/01/09 01:04:33 $
12 # (c) Copyright 2006, ClearSCM, Inc. all rights reserved
14 ################################################################################
63 eval { require Net::LDAP };
66 return $FALSE, "Unable to load Net::LDAP. LDAP validation not possible.";
69 my $ldap = Net::LDAP->new ($server,
74 return $FALSE, "Unable to connect to $server:$port" if !$ldap;
76 if (!$ldap->bind (version => 3)) {
77 return $FALSE, "Unable to bind to $server:$port";
80 my @attribute = ($account_attribute);
81 my $key = $search_filter;
82 $key =~ s/\%login\%/$search_for/;
84 my $result = $ldap->search (base => $base,
92 my $entry = $result->entry;
95 my $value = $entry->get_value ($account_attribute);
96 return $TRUE, "Matched $key to LDAP";
98 return $FALSE, "Unable to find entry ($key)";
104 my $admin_username = shift;
105 my $admin_passwords = shift;
109 my $cmd = "installutil getldapinit $dbset $admin_username $admin_passwords";
113 carp "Unable to execute $cmd" if $?;
120 if (/Exit code (\d*)/) {
125 $LDAPSettings {ldapinit} .= "$_\n";
128 $cmd = "installutil getldapsearch $dbset $admin_username $admin_passwords";
132 croak "Unable to execute $cmd" if $?;
139 if (/Exit code (\d*)/) {
144 $LDAPSettings {ldapsearch} .= "$_\n";
147 $cmd = "installutil getcqldapmap $dbset $admin_username $admin_passwords";
151 croak "Unable to execute $cmd" if $?;
158 if (/Exit code (\d*)/) {
163 $LDAPSettings {cqldapmap} .= "$_\n";
166 return %LDAPSettings;