On 16/8/03 3:53 am, Darryl C Price <[EMAIL PROTECTED]> wrote:

> I'm trying to use the Net::LDAP::Schema with perl-ldap 0.29 .... can't figure
> out how the heck the must method works now.   It use to turn a list of scalar
> variables.  Now it returns hash references.  What happened?  How am I supposed
> to get attribute, objectclass names, oids, etc .. now?  There are no examples,
> that I've been able to find nor are there any explanations.  Hoping you can
> provide me with one:

Try looking at Net::LDAP::Examples. Well actually don't bother if you've
only got the released version, because it is wrong :-(

I fixed the schema-related examples and schema documentation post-0.29 so
they actually correspond more to the code.

Here's the current version of Schema.pod from CVS:

<http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/perl-ldap/ldap/lib/Net/LDAP/
Schema.pod?rev=1.13&content-type=text/vnd.viewcvs-markup>
 
I guess the documentation of the must() and may() methods needs some
tweaking to describe the HASHes coming back. I overlooked those methods,
sorry! The documentation of the all_*() methods briefly describes the HASH
keys.

The current version of Examples.pod from CVS:

<http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/perl-ldap/ldap/lib/Net/LDAP/
Examples.pod?rev=1.8&content-type=text/vnd.viewcvs-markup>

It has an example right at the bottom of using the schema HASHes.

>  if (scalar(@classdefs) >= 1) {
>       $ldap = Net::LDAP->new($hname,port => 389, version =>3, debug => 0);
>       if (defined $ldap) {
>           $mesg = $ldap->bind($binddn, password => $bindpw);
>           if ($mesg->code == 0) {
>               $schema = $ldap->schema();
>               foreach $classname ( @classdefs ) {
>                   @must = $schema->must($classname);
>                   if (scalar(@must) >= 1) {
>                       foreach $attr ( @must ) {
>                           print STDERR "Required Attribute found:
> ",$attr,"\n";

Try printing:

    $attr->{name}

(assuming the attributes have names. They're not required to have names :-)

>                           push @mustattrs,$attr;
>                       }
>                   }
>               }
> 
>               foreach $classname ( @classdefs ) {
>                   @may = $schema->may($classname);
>                   if (scalar(@may) >= 1) {
>                       foreach $attr ( @may ) {
>                           print STDERR "Optional Attribute found:
> ",$attr,"\n";

Ditto.

Cheers,

Chris

Reply via email to