[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: dhcp.schema attribute dhcpStatements value in filter
- To: openldap-technical@openldap.org, "Zeus Panchenko" <zeus@ibs.dn.ua>
- Subject: Re: dhcp.schema attribute dhcpStatements value in filter
- From: Harry Jede <harry.jede@arcor.de>
- Date: Wed, 2 Apr 2014 00:26:19 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=arcor.de; s=mail-in; t=1396391180; bh=IKERU8ke4l4ZAjxNuhr/Zi3/FDcubUM3klzdZgY87Dw=; h=From:To:Subject:Date:References:In-Reply-To:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id; b=dobqkKCGcom/8ZKoHsEKQ0M+F16suIRU7J2n/UNqpniFmvxMOYE4yb3RFwPRO7lBf S+VfZ1AA8VBE0gtx6gp3xFnrbFP1/3M+2nUXf5qAwYAcurmy41jJuOa62nBX6xfroH huugqVRdTvNR7zSJK8ygOH7Kyn0/M8hzIgSXx6tY=
- In-reply-to: <201404012345.15270.harry.jede@arcor.de>
- References: <201404012345.15270.harry.jede@arcor.de>
- User-agent: KMail/1.13.7 (Linux/3.2.0-4-amd64; KDE/4.8.4; x86_64; ; )
Harry Jede wrote:
> 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 :-)
Sorry,
I have overseen that you are using slapd.conf.
So it is much easier. Just modify dhcp.schema and restart slapd.
--
Harry Jede