[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-ldap-dev
Subject:    RE: What's wrong with Net::LDAP::Schema?
From:       "Darryl C Price" <darryl () convsys ! com>
Date:       2003-08-16 15:09:41
[Download RAW message or body]

No worries,  I added code to manually iterate through the key/value
pairs to figure out what was actually in the hash.  Felt pretty stupid
afterwards:

 foreach $classname ( @classdefs ) {
     @mustlist = $schema->must("$classname");
     foreach $attr ( @mustlist ) {
         while ( my ($key, $value) = each(%$attr) ) {
             print "$key => $value\n";
         }
     }
 }


--Darryl

> -----Original Message-----
> From: Chris Ridd [mailto:chrisridd@mac.com] 
> Sent: Saturday, August 16, 2003 1:35 AM
> To: Darryl C Price; perl-ldap@perl.org
> Subject: Re: What's wrong with Net::LDAP::Schema?
> 
> 
> On 16/8/03 3:53 am, Darryl C Price <darryl@convsys.com> 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/L
DAP/
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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic