Overview
We want to map the following entry in the hosts NIS map:
192.168.1.10 www.example.com www
into the following LDAP entry in Penrose:
dn: cn=www.example.com,ou=Hosts,dc=NIS,dc=Example,dc=com objectClass: device objectClass: ipHost ipHostNumber: 192.168.1.10 cn: www.example.com cn: www
Configuration
Define the following source in sources.xml:
<source name="hosts"> <connection-name>NIS</connection-name> <field name="cn"/> <field name="ipHostNumber" primaryKey="true"/> <parameter> <param-name>objectClasses</param-name> <param-value>ipHost</param-value> </parameter> <parameter> <param-name>base</param-name> <param-value>hosts.byaddr</param-value> </parameter> </source>
Then define the following entry in directory.xml:
<entry dn="cn=...+ipHostNumber=...,ou=Hosts,dc=NIS,dc=Example,dc=com"> <entry-class>org.safehaus.penrose.nis.directory.NISEntry</entry-class> <oc>device</oc> <oc>ipHost</oc> <at name="cn" rdn="true"> <expression> import java.util.*; if (h.cn instanceof Collection) { return h.cn.iterator().next(); } return h.cn; </expression> </at> <at name="cn"> <variable>h.cn</variable> </at> <at name="ipHostNumber" rdn="true"> <variable>h.ipHostNumber</variable> </at> <source alias="h"> <source-name>hosts</source-name> <field name="cn"> <variable>cn</variable> </field> <field name="ipHostNumber"> <variable>ipHostNumber</variable> </field> </source> </entry>
