From 73113888e00a32c9caacc0651a3fef49c310f252 Mon Sep 17 00:00:00 2001 From: Frank Dillon Date: Fri, 7 Sep 2007 21:41:42 +0000 Subject: [PATCH] Fixed a bug that wouldn't allow anonymous binds. Added a few API methods to make it easier to get data from the object --- lib/WebGUI/LDAPLink.pm | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/lib/WebGUI/LDAPLink.pm b/lib/WebGUI/LDAPLink.pm index 775615587..bda82b4e8 100644 --- a/lib/WebGUI/LDAPLink.pm +++ b/lib/WebGUI/LDAPLink.pm @@ -69,13 +69,7 @@ sub bind { if ($ldapUrl eq "") { $self->{_error} = 100; return 0; - } elsif ($connectDn eq "") { - $self->{_error} = 101; - return 0; - } elsif ($identifier eq "") { - $self->{_error} = 102; - return 0; - } + } if ($uri = URI->new($ldapUrl)) { unless ($ldap = Net::LDAP->new($uri->host, (port=>($uri->port || 389)))) { @@ -89,6 +83,7 @@ sub bind { } elsif($auth->code > 0) { $self->{_error} = $auth->code; } + $self->{_uri } = $uri; $self->{_connection} = $ldap; } else { $self->{_error} = 105; @@ -161,6 +156,33 @@ sub getList { #------------------------------------------------------------------- +=head2 getURI ( ) + +Returns the uri object for the ldap connection. + +=cut + +sub getURI { + my $self = shift; + return $self->{_uri}; +} + +#------------------------------------------------------------------- + +=head2 getValue ( property ) + +Returns the value of the property passed in. + +=cut + +sub getValue { + my $self = shift; + my $prop = shift; + return $self->get->{$prop}; +} + +#------------------------------------------------------------------- + =head2 unbind ( ) Disconnect cleanly from the current databaseLink. @@ -198,7 +220,7 @@ sub new { my $session = shift; $ldapLinkId = shift; return undef unless $ldapLinkId; - $ldapLink = $session->db->quickHashRef("select * from ldapLink where ldapLinkId=".$session->db->quote($ldapLinkId)); + $ldapLink = $session->db->quickHashRef("select * from ldapLink where ldapLinkId=?",[$ldapLinkId]); bless {_session=>$session, _ldapLinkId=>$ldapLinkId, _ldapLink=>$ldapLink }, $class; }