On 10/12/03 6:55 pm, Graham Barr <[EMAIL PROTECTED]> wrote:
> Begin forwarded message:
>> From: "D.Kreft" <[EMAIL PROTECTED]>
>> Date: 10 December 2003 18:44:25 GMT
>> To: Graham Barr <[EMAIL PROTECTED]>
>> Subject: Net::LDAP data accessors
>> Message-Id:
>> <[EMAIL PROTECTED]>
>>
>> Hey Graham,
>>
>> One tiny suggestion for your next release of Net::LDAP...
>>
>> Could you add some data accessors to the API? Currently, one must
>> violate
>> the encapsulation of an object to get the hostname from the object when
>> reporting errors, for example:
>>
>> if ( [EMAIL PROTECTED] ) {
>> # HACK ALERT!
>> # I know, I know...violating an objects encapsulation is bad.
>> # But the authors of Net::LDAP didn't include an accessor
>> # for this data into verison 0.2701, so I am left with no other
>> # choice. At least I'm providing for a sensible default in case
>> # the authors/maintainers decide to change things around under
>> the
>> # covers.
>> my $host = $ldap->{'net_ldap_host'} || 'Server';
>>
>> my $error = sprintf("%s returned code %s (\"%s\"), "
>> . "but no urls could be found",
>> $host,
>> $code,
>> $message->error() || '');
>>
>> Carp::croak($error);
>> }
>>
>> In general, it's not possible to know what host a particular instance
>> of
>> Net::LDAP is tied to without reaching under the covers and fondling
>> the data
>> (which I would rather not do), espeically when the object is created
>> in one
>> place and then passed to another subroutine/method.
>>
>> Accessors for other things like port number, binddn and other stuff
>> would
>> also be very useful.
$ldap->socket->peername returns the peer address and port. $ldap->socket's
documented as well ;-)
The bind DN isn't kept around, so there's no need for an accessor. Of course
there may not be a bind DN (eg in SASL binds) anyway. Is this a useful thing
to add?
Cheers,
Chris