[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: dhcp.schema attribute dhcpStatements value in filter
- To: openldap-technical@openldap.org
- Subject: Re: dhcp.schema attribute dhcpStatements value in filter
- From: Harry Jede <harry.jede@arcor.de>
- Date: Tue, 1 Apr 2014 23:45:15 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=arcor.de; s=mail-in; t=1396388715; bh=N9kNBPj7/OZRN6iUlyZY0acAYi/rE1Xby6yvEyg/7tY=; h=To:Subject:From:Date:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id; b=gCJpcQWxU3qPY1Yp+zn8ZSnl8RNQDF6lnMLtUQKbtOUtcokpqe9V8k7P9iT5LMbTl icV6aVg3QcPTKwTUOFG4tOpW3yq9PPlUEviwVT+DMYSy7Yo0vjKbe9FGKcTo/sG0Ug 9HyLb9iC42RRUS+7HpXPQZgGKDNgyLEHYY2YMUI8=
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 10.0.0.222))"
>
> and receive empty result ...
Then you make a mistake :-(
$ ldapsearch -xLLL -H ldap://10.100.0.1 '(&(objectclass=dhcphost)
(dhcpStatements=fixed-address 10.100.0.102))' dn dhcpStatements
dn: cn=DEBIAN,ou=hosts,cn=DHCP Config,dc=europa,dc=xx
dhcpStatements: fixed-address 10.100.0.102
> 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 10.0.0.2* ?
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
dhcp
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.1.203.4.3 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 1.3.6.1.4.1.1466.115.121.1.26 )
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://10.100.0.1 '(&(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 10.100.0.101
dn: cn=ainf-02,ou=hosts,cn=DHCP Config,dc=europa,dc=xx
dhcpStatements: fixed-address 10.100.0.103
dhcpStatements: filename "pxelinux.0"
dhcpStatements: next-server 10.100.0.1
dhcpStatements: broadcast-address 10.100.255.255
dn: cn=ainf-22,ou=hosts,cn=DHCP Config,dc=europa,dc=xx
dhcpStatements: fixed-address 10.100.0.104
dn: cn=DEBIAN,ou=hosts,cn=DHCP Config,dc=europa,dc=xx
dhcpStatements: fixed-address 10.100.0.102
hints:
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