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

List:       perl-ldap-dev
Subject:    Re: [Fwd] retrieve perl-ldap schema and ldap search
From:       Jim Harle <harle () usna ! edu>
Date:       2000-06-29 18:47:01
[Download RAW message or body]

Eric,
  I have attached code that will find all attributes without using
ldap->schema().

  For your second question, it depends on what you want to really search
for.  If all you want to know is whether an object of a given dn exists,
you can use code like
  $mesg = $ldap->search ( 
          base => $testdn,
          scope => 0,
          filter => "(objectclass=*)" );
If the search succeeds, $testdn already exists.

If you, however, want to make sure that you are adding an object where the
lowest level of the dn is unique, the search is different.  This might be
when you are looking to add a user with uid=joe, but you want to make sure
that not only is there not a "joe" in dept1, but not anywhere.  If this is
the case, then you need to make sure that all your users have a uid
attribute, not just uid as part of the dn.  Then the search becomes
  $mesg  = $ldap->search (
           base => $normalbase
           filter => "(uid=$testuid)" );

  Jim Harle
  US Naval Academy


On Thu, 29 Jun 2000, Graham Barr wrote:

> ----- Forwarded message from Eric Zhou <eric_x_zhou@yahoo.com> -----
> 
> Date: Thu, 29 Jun 2000 10:55:36 -0700 (PDT)
> From: Eric Zhou <eric_x_zhou@yahoo.com>
> Subject: retrieve perl-ldap schema and ldap search
> To: Graham Barr <gbarr@pobox.com>
> 
> hi,Graham:
> 
> remember I asked you an address the other day about
> two perl module. I am still not that far yet.
> I have been able to use ldap->add() and ldap->modify()
> function to do some simple stuff.
> 
> do you have some handy example of how to use
> ldap->schema to retrieve schema of ldap tree?
> the other thing is that I don't quite understand 
> your ldap->search() doing. because I wish to search 
> and dn in the ldap tree and see if it is there before
> I insert it. do I suppose to use ldap->search() or 
> ldap->compare().
> 
> 
> thank you very much.
> 
> Eric 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get Yahoo! Mail - Free email you can access from anywhere!
> http://mail.yahoo.com/
> 
> ----- End forwarded message -----
> 
> 

["findallattrs" (TEXT/PLAIN)]

#!/usr/local/bin/perl

use Net::LDAP;
use Net::LDAP::Util;

$ldap = Net::LDAP->new('mydirectoryserver') or die "$@";

$ldap->bind (version => 3) or die $@; 
$mesg = $ldap->search (  # search for the subschemasubentry object
                  scope => base,
                  filter => "(objectclass=*)",
                  attrs => ["subschemasubentry"]
             );
my ($entry) = $mesg->all_entries;
my ($newbase) = $entry->get("subschemasubentry");
$mesg = $ldap->search (  # perform a search
                  scope => base,
                  base   => $newbase,
                  filter => "(objectclass=*)",
                  attrs => ["objectclasses"]
             );
print Net::LDAP::Util::ldap_error_text($mesg->code),"\n" if $mesg->code;
foreach $entry ($mesg->all_entries) {
  $entry->dump; 
}
  
$ldap->unbind;   # take down session



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

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