On Monday, July 21, 2003, at 10:57PM, Sante Jonker <[EMAIL PROTECTED]> wrote:
> >I am new to LDAP. While reading the documentation and the source I became >confused concerning some functions in Schema.pm. Perhaps my lack of >knowledge concerning LDAP or perl is causing my confusion. > >The functions on lines 113 through 120 of Schema.pm all return hash >references but the documentation suggest that they will return names: > >http://search.cpan.org/author/GBARR/perl-ldap/lib/Net/LDAP/Schema.pod#METHODS > >"all_attributes >all_ditcontentrules >... > Returns a list of the names all the requested type in the schema" You're right. >The example of printing a schema also works better if those functions >return names. > >http://search.cpan.org/author/GBARR/perl-ldap/lib/Net/LDAP/Examples.pod#LDAP_SCHEMA_RETRIEVAL > >A way to do this is to change the source for those functions to return >keys and not values. Well, the example's just wrong now. Since the all_attributes method's returned everything the module knows about every attribute, there's enough info to print the attribute details directly instead of using extra calls to the attribute method. Try this code: my $schema = $ldap->schema(); my (@attrs) = $schema->all_attributes; foreach my $ar (@attrs) { print "attributeType: ", $ar->{name}, "\n"; foreach my $key ( keys %{$ar} ) { print join("\n\t\t", "\t$key:", ref($ar->{$key}) ? @{$ar->{$key}} : $ar->{$key}), "\n"; } } It works for me, but then I previously tested the schema retrieval code in the perldoc and thought that worked too! (Perhaps we changed the API subsequently and I forgot to update the example.) >Sante' Jonker >IT Manager >ALTEC (Anderson Language Technology Center) >University of Colorado at Boulder > > Cheers, Chris
