On Tue, 26 Sep 2006 13:06:54 -0700
Glenn Lamb <[EMAIL PROTECTED]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Adding an ampersand to the start of your filter ($filter="& 
> (objectClass=...") should work just fine.
> However, if you really want to nest:
> 
> my $filter = "(&(objectClass=dhcpHost)(objectClass=mwcDHCPhost)";
> $filter .= "(dhcpStatements=fixed-address " . $config{ip}. ")" if  
> defined($config{ip});
> $filter .= "(mwcDHCPhostAuthedAs=" . $config{user} . ")"       if  
> defined($config{user});
> $filter .= "(dhcpHWAddress=ethernet " . $config{mac} . ")"     if  
> defined($config{mac});
> $filter .= ")";
> 
> On Sep 26, 2006, at 12:52 PM, Zane C. Bowers wrote:
> 
> > my $filter="(objectClass=dhcpHost)(objectClass=mwcDHCPhost)";
> > if (defined($config{ip})){$filter.="(dhcpStatements=fixed-address
> > ". $config{ip}.")";};
> > if
> > (defined($config{user})){$filter.="(mwcDHCPhostAuthedAs=".$config
> > {user}.")";}; if
> > (defined($config{mac})){$filter.="(dhcpHWAddress=ethernet ".
> > $config{mac}.")";};
> >
> > That is how I originally started building a filter. The problem
> > was it did not
> > work. The problem is it will generate a filter that will work with  
> > ldapsearch,
> > but will not work with Net::LDAP.
> >
> > After reading the RFC and doing a bit of testing, I found
> > "(&(objectClass=dhcpHost)(objectClass=mwcDHCPhost))" will work,
> > but it needs
> > to be done in groups of layered.
> >
> > Before I set out to most likely re-invent the well, any one know
> > of any
> > existing solutions for this?

After a bit of thinking I came up with this a few minutes ago...

my $filter="(&(objectClass=mwcDHCPhost)(objectClass=dhcpHost))";
if (defined($config{ip})){$filter="(&(dhcpStatements=fixed-address 
".$config{ip}.")".$filter.")";}; if 
(defined($config{user})){$filter="(&(mwcDHCPhostAuthedAs=".$config{user}.")".$filter.")";};
if (defined($config{mac})){$filter="(&(dhcpHWAddress=ethernet 
".$config{mac}.")".$filter.")";};


Thanks though. :)



Attachment: signature.asc
Description: PGP signature

Reply via email to