NIS Services

Goal

We want to map the following entries from /etc/services:

ftp             21/tcp
ftp             21/udp          fsp fspd

into the following LDAP entry in Penrose:

dn: cn=ftp,ou=Services,dc=NIS,dc=Example,dc=com
objectClass: ipService
ipServiceProtocol: tcp
ipServiceProtocol: udp
ipServicePort: 21
cn: ftp
cn: fsp
cn: fspd

Solution

First we create the source:

<source name="services">

    <connection-name>NIS</connection-name>

    <field name="name"/>
    <field name="cn"/>
    <field name="ipServicePort" primaryKey="true"/>
    <field name="ipServiceProtocol" primaryKey="true"/>
    <field name="description"/>

    <parameter>
      <param-name>objectClasses</param-name>
      <param-value>ipService</param-value>
    </parameter>
    <parameter>
      <param-name>base</param-name>
      <param-value>system/services.byname</param-value>
    </parameter>
    <parameter>
      <param-name>scope</param-name>
      <param-value>ONELEVEL</param-value>
    </parameter>
    <parameter>
      <param-name>dataCacheSize</param-name>
      <param-value>500</param-value>
    </parameter>

 </source>

Then we create the mapping:

<entry dn="cn=...,ou=Services,dc=NIS,dc=Example,dc=com">

    <oc>ipService</oc>

    <at name="cn" rdn="true">
      <variable>s.name</variable>
    </at>
    <at name="cn">
      <variable>s.cn</variable>
    </at>
    <at name="ipServicePort">
      <variable>s.ipServicePort</variable>
    </at>
    <at name="ipServiceProtocol">
      <variable>s.ipServiceProtocol</variable>
    </at>
    <at name="description">
      <variable>s.description</variable>
    </at>

    <source name="s">
      <source-name>services</source-name>
      <field name="cn">
        <variable>cn</variable>
      </field>
      <field name="ipServicePort">
        <variable>ipServicePort</variable>
      </field>
      <field name="ipServiceProtocol">
        <variable>ipServiceProtocol</variable>
      </field>
      <field name="description">
        <variable>description</variable>
      </field>
    </source>

    <parameter>
      <param-name>dataCacheSize</param-name>
      <param-value>500</param-value>
    </parameter>

</entry>

Performance Issue

Since the number of services is usually large and Penrose has to download everything before it can merge them, this particular mapping is quite slow. You can enable Cache to improve the performance.