[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: dhcp.schema attribute dhcpStatements value in filter

Zeus Panchenko wrote:
> hi,
> I configured my isc-dhcpd servers to work with openldap, all works
> now when I want to find dn for some definite MAC or IP, I am unable
> to do that

> I use filter:
> "(&(objectClass=dhcpHost)(dhcpStatements=fixed-address"
> and receive empty result ...
Then you make a mistake :-(

$ ldapsearch -xLLL -H ldap:// '(&(objectclass=dhcphost)
(dhcpStatements=fixed-address' dn dhcpStatements
dn: cn=DEBIAN,ou=hosts,cn=DHCP Config,dc=europa,dc=xx
dhcpStatements: fixed-address

> it is the same picture for anything except dhcpStatements=* ...
> so, how is it correct to write the filter to get all objects with IP
> like* ?
By default, that's not possible. You need to modify the schema to make 
this work.

step 1: find the dhcp schema

# ldapsearch -LLLY external -H ldapi:/// -b cn=schema,cn=config dn|grep 
dn: cn={7}dhcp,cn=schema,cn=config

step2: prepare a ldapmodify input file

# echo 'dn: cn={7}dhcp,cn=schema,cn=config' >  /tmp/dhcp_s.ldif
# echo 'changetype: modify'                 >> /tmp/dhcp_s.ldif
# echo 'replace: olcAttributeTypes'         >> /tmp/dhcp_s.ldif

step 3: retrieve the attributes from cn=config

# ldapsearch -LLLY external -H ldapi:/// -b cn=schema,cn=config 
'cn={7}dhcp' olcAttributeTypes >> /tmp/dhcp_s.ldif

step 4.1: add Substring match to dhcpStatements with an editor

this I have added "SUBSTR caseIgnoreIA5SubstringsMatch" to 
dhcpStatements. The result is:

olcAttributeTypes: {2}( 2.16.840.1.113719. NAME 
'dhcpStatements' DESC 'Flexible storage for specific data depending on 
what object this exists in. Like conditional statements, server 
parameters, etc. This allows the standard to evolve without needing to 
adjust the schema.' EQUALITY caseIgnoreIA5Match SUBSTR 
caseIgnoreIA5SubstringsMatch SYNTAX )

step 4.2 remove line number 4
in my config 'dn: cn={7}dhcp,cn=schema,cn=config'

step 5: update the server

# ldapmodify -Y external -H ldapi:/// -f /tmp/dhcp_s.ldif 

step 6: be happy ;-)

$ ldapsearch -xLLL -H ldap:// '(&(objectclass=dhcphost)
(dhcpStatements=fixed-address 10.100.0.*))' dn dhcpStatementsdn: 
cn=ainf-01,ou=hosts,cn=DHCP Config,dc=europa,dc=xx
dhcpStatements: fixed-address

dn: cn=ainf-02,ou=hosts,cn=DHCP Config,dc=europa,dc=xx
dhcpStatements: fixed-address
dhcpStatements: filename "pxelinux.0"
dhcpStatements: next-server
dhcpStatements: broadcast-address

dn: cn=ainf-22,ou=hosts,cn=DHCP Config,dc=europa,dc=xx
dhcpStatements: fixed-address

dn: cn=DEBIAN,ou=hosts,cn=DHCP Config,dc=europa,dc=xx
dhcpStatements: fixed-address

1. modify an objectclass this way, will not work
2. an index on dhcpStatements is not required to make this work
   perhaps good for performance reasons
3. try it first on a test server :-)


Harry Jede