<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Generating RDF Models from LDAP Directories</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>University of Leipzig Institute for Medical Informatics, Statistics and Epidemiology</institution>
          ,
          <addr-line>IMISE</addr-line>
        </aff>
      </contrib-group>
      <abstract>
        <p>Lightweight Directory Access Protocol (LDAP) has gained importance as a database technology for the storage and retrieval of information on network and human resources. This paper describes a method to create RDF models from a directory information tree or an LDAP search query by mapping LDAP schema information into OWL ontologies and LDAP objects into RDF instance triples. Furthermore, it reports on an implementation of this method based on the RDF API for PHP.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        LDAP was specified by the IETF to provide an easier access to directory services
from internet clients via TCP/IP. Since 1997 LDAP v3 servers [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] have found
wide distribution for the storage of information about network and human
resources. In LDAP directories, all objects consist of pairs of attribute names and
values, they are arranged in a directory information tree (DIT) and get a
distinguished name (DN), which is build from the relative DN (RDN, simply a
selected name-value pair) and the RDN of all parent objects. Every object is an
instance of exactly one structural object class and possibly more than one
auxiliary object classes. By this instantiation, different attribute types were allowed
or enforced. The object classes, attribute types and other metadata are defined
in the directory’s schema. Various object classes are standardized by the IETF
(e.g. inetOrgPerson [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]) and target at common tasks for directories such as the
usage as a central authorisation component in a network1.
      </p>
      <p>
        With respect to the Semantic Web it is important to reuse existing data
and schemata in LDAP directories within the Resource Description Framework
(RDF, [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]). This means that there has to be a method which allows the
conversion of an LDAP schema specification into OWL ontologies. Thus we can map
converted classes and properties with all kinds of Semantic Web vocabularies like
FOAF and Dublin Core. The resulting OWL ontology must keep the cardinality
restrictions and the attribute syntax. It must also allow the reproduction of the
DIT.
      </p>
      <p>
        This paper is divided into three parts. Section 1 will describe the method to
generate an OWL ontology from a LDAP schema. On the basis of this, section
1 For a more complete introduction to LDAP see [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], chapter 3.
2 shows how RDF models are generated from LDAP objects. Finally, an PHP
implementation based on the PHP API RAP [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] will be explained briefly in
section 3.
1
      </p>
    </sec>
    <sec id="sec-2">
      <title>Conversion of a LDAP directory schema</title>
      <p>The schema specification of an LDAP server consists of four parts: the definition
of object classes and attribute types, and an index of attibute syntaxes and
matching rules implemented on the server. Every class, type, syntax and rule
is globally identified by an object identifier (OID2) and locally by one or more
mnemonic names.</p>
      <p>An requirement for the whole process is a small vocabulary which describes
base entities of the LDAP world: object is the class of all LDAP objects and
hasDITChild / hasDITParent is a pair of (inverse) functional object relations
who represent the DIT structure. For a one-way conversion of existing LDAP
data into RDF data, only this basic vocabulary is necessary. A more complete
LDAP schema ontology will be presented in [7]3.</p>
      <p>The next three subsections explain the rules of how to convert a LDAP
schema with types and classes to an OWL ontology.
1.1</p>
      <p>Attribute syntax
Because the different attribute syntaxes (e.g. the telephone number syntax or
the integer syntax) are only named in the schema but not declared, dealing with
them can only be achieved by a mapping table in which each syntax OID is put
together with the URI of its matching XML Schema datatype. Most of them can
simply be matched with xsd:string4, but in some cases we can map to more
specific datatypes or we must bear in mind other constraints. These exceptions
are:
– The DN and OID syntax must be ignored, because attributes of this type
are transformed into object properties.
– The values of any binary syntax attributes should be recoded as the XML</p>
      <p>
        Schema datatype xsd:base64Binary.
– The Directory String syntax should be xsd:normalizedString because no
new lines are allowed here.
– Numeric syntaxes must be mapped to an equivalent numeric XML Schema
datatype, if possible.
2 OID are strings of dot-separated numbers which form a hierarchical structure. They
were first specified in the ITU-T recommendation X.208 (ASN.1) and are used to
identify objects in the broadest sense. An OID can be transformed into an URN by
using the prefix urn:oid: [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
3 The actual version of this vocabulary is available from the persistant URL
http://purl.org/net/ldap . Within this paper, the namespace ldap is assigned
to this URL.
4 Assuming the namespace xsd is assigned to http://www.w3.org/2001/XMLSchema.
– Special syntaxes like the syntax for telephone numbers can be accurately
defined by regular expressions in a non-standard XML Schema document.
– Some syntaxes are suited to be used as URIs too. Optionally telepone
numbers can be used with the tel URI scheme [8] and labeledURI attributes
have to be splitted into a resource and its rdfs:label.
In addition to the syntax, every attribute type schema definition consists of
an OID, one or more local names and optionally a description and a single
value indicator. An attribute may be the sub-attribute of another attribute, e.g.
commonName and title are sub-attributes of name. This simply means that the
syntax of the sub-attribute derives from the super-attribute, in particular this
does not provide any clue about any specific relation between the sub-attribute
and the super-attribute.
      </p>
      <p>Each attribute schema definition will be transformed into OWL according to
the following implementation rules:
– Every attribute with the syntax of an OID or a DN is created as an object
property while all others become datatype properties6.
– If there is a super-attribute, the RDFS relation rdfs:subPropertyOf should
be used.
– Object properties get as range the class top7 and datatype properties the
matching XML Schema syntax.
– Local names are used as part of the URI of the new property. The first URI is
described explicitly, any other URI and the OID (in URN form) are mapped
with owl:equivalentProperty to the first one.
– The local name should also be used as the value of a rdfs:label property.
5 Assumimg the OID prefix wm is set to 1.3.6.1.4.1.1466.115.121.1 .
6 In general, the OID syntax is only used in administrative attributes.
7 According to RFC 2251, the root of any schema class hierarchy has to be top.
– If there is a single value indicator in the schema definition, then a cardinality
restriction (≤ 1) for the class top must be created on this property8.
– The domain of the property will be generated with the owl:unionOf class
constructor and the list of all object classes which use this attribute (no need
for owl:unionOf if there is only one domain class).</p>
      <p>An example for a transformed LDAP attribute is presented with the next
lines of RDF/XML code. In the sample schema, the single value attribute countryName
is only used in the object class country, therefore its domain is given by country.
The schema definition of an object class can contain two different reference types
to an attribute. It depends on this type whether an attribute is mandatory
in all objects of this class (MUST) or whether it is allowed and optional (MAY).
Furthermore, the definition consists of a local name, an OID and an optional
description. All classes are arranged in a subclass hierarchy whose root is the class
top. Subclasses inherit all attribute conditions of its superclasses9. To generate
OWL classes from LDAP schema classes, these implementation rules must be
followed:
– The local name must be used as part of the URI of the new OWL class.</p>
      <p>Additionally, the OID (in URN form) is mapped with owl:equivalentClass
to the class. It is theoretically possible to create an ontology only by using
URN-formed OIDs but in fact, many tools do not support URNs so it is
more workable to generate a new URL for each class (and property).
8 Using top instead of the domain classes is necessary because the single value
restriction is set for the whole LDAP schema and not for the particular domain classes.
9 In an LDAP schema more than one direct superclass is possible.
– The local name should also be used as the value of a rdfs:label property.
– For every mandatory attribute of the object class a new cardinality
restriction (= 1) has to be created on the OWL class.
– The new class has to be in rdfs:subClassOf-relation with its superclass(es)
(in most cases just top). top must be defined as a subclass of the generic
LDAP object class ldap:object from [9].</p>
      <p>As an example, the next XML listing shows the converted standard object
class country which has the mandatory attribute countryName.
1 &lt;owl : Class rdf : about ="# country "&gt;
2 &lt; rdfs : label &gt; country &lt;/ rdfs : label &gt;
3 &lt; rdfs : subClassOf rdf : resource ="&amp; ldap ; top " /&gt;
4 &lt;owl : equivalentClass rdf : resource =" urn : oid :2.5.6.2"/ &gt;
5 &lt; rdfs : comment &gt; RFC2256 : a country &lt;/ rdfs : comment &gt;
6 &lt; rdfs : subClassOf &gt;
7 &lt;owl : Restriction &gt;
8 &lt;owl : cardinality &gt;1 &lt;/ owl : cardinality &gt;
9 &lt;owl : onProperty rdf : resource ="# c" /&gt;
10 &lt;/ owl : Restriction &gt;
11 &lt;/ rdfs : subClassOf &gt;
12 &lt;/ owl : Class &gt;</p>
      <p>The resulting OWL schema requires at least OWL DL because of the owl:unionOf
class constructor.
2</p>
    </sec>
    <sec id="sec-3">
      <title>Conversion of a LDAP directory information tree</title>
      <p>To convert the directory objects from a DIT into an RDF model, the classes
and properties of the previously created OWL ontology and the basic LDAP
ontology have to be used. While doing this, these steps have to be followed:
– Construct the URI of the LDAP object according to RFC 1959 [10]. This
means that the object gets an URI in the form ldap://[host]/[URL encoded
DN], e.g. ldap://ldap.example.org/c=de.
– Identify the main structural object class in order to take this as the rdf:type
of the object. Any auxiliary classes become additional types.
– Convert all attribute values from DN and OID syntax attributes into
resources and create that object property triple.
– Convert all other attribute values to literals10 and create a datatype property
triple.
– Use the objects RDN value as a rdfs:label.</p>
      <p>As a result of this process, a typical LDAP object of the organization type
gets an RDF representation which looks like this:
10 Binary values have to be encoded as xsd:base64Binary.
1 &lt; organization rdf : about =" ldap :// example . org /o= IMISE ,c= de "&gt;
2 &lt; rdf : type rdf : resource ="# labeledURIObject " /&gt;
3 &lt; rdfs : label &gt; IMISE &lt;/ rdfs : label &gt;
4 &lt;o &gt; IMISE &lt;/o &gt;
5 &lt; telephoneNumber &gt;+49 341 97 16100 &lt;/ telephoneNumber &gt;
6 &lt; labeledURI &gt; http :// www . imise . de / &lt;/ labeledURI &gt;
7 &lt; description &gt; Institute for ... &lt;/ description &gt;
8 &lt; ldap : hasParent rdf : resource =" ldap :// example . org /c= de "/ &gt;
9 &lt;/ organization &gt;</p>
      <p>With this method it is possible to convert a complete LDAP directory
including schema and data. At the same time only parts of a DIT, e.g. a result
set of an LDAP query can be converted into and reused in RDF. In the next
section, I will briefly explain an PHP implementation that is based on the PHP
API RAP.</p>
    </sec>
    <sec id="sec-4">
      <title>3 Implementation</title>
      <p>As a proof of the concept, I have implemented the method in the server-side
script language PHP as a web application using the wrapper functions to the
OpenLDAP library and classes for the schema and server handling from the
open-source project phpLDAPadmin on the LDAP side as well as the PHP API
RAP on the RDF side.</p>
      <p>Implementation was rather simple because all the used libraries are mature
and well-documented projects. For the test run, I converted the IMISE LDAP
Server with over 300 schema items and 2300 DIT objects into RDF. The current
version of the ldap2owl.php script is free accessable11.
11 http://purl.org/net/ldap/ldap2owl.php
7. Dietzold, S.: LDAP and the Semantic Web. in preparation (2005)
8. Schulzrinne, H.: The tel URI for Telephone Numbers. RFC 3966, The Internet</p>
      <p>Engineering Task Force (IETF) (2004) http://www.ietf.org/rfc/rfc3966.txt.
9. Dietzold, S.: Basic vocabulary to use LDAP data in RDF. OWL ontology (2005)
http://purl.org/net/ldap.
10. Howes, T.A., Smith, M.C.: An LDAP URL Format. RFC 1959, The Internet
Engineering Task Force (IETF) (1996) http://www.ietf.org/rfc/rfc1959.txt.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Wahl</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Howes</surname>
            ,
            <given-names>T.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kille</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Lightweight Directory Access Protocol (v3)</article-title>
          .
          <source>RFC 2251</source>
          ,
          <article-title>The Internet Engineering Task Force (IETF) (</article-title>
          <year>1997</year>
          ) http://www.ietf.org/rfc/rfc2251.txt.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Smith</surname>
            ,
            <given-names>M.C.</given-names>
          </string-name>
          :
          <article-title>Definition of the inetOrgPerson LDAP Object Class</article-title>
          .
          <source>RFC 2798</source>
          ,
          <article-title>The Internet Engineering Task Force (IETF) (</article-title>
          <year>2000</year>
          ) http://www.ietf.org/rfc/rfc2798.txt.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Howes</surname>
            ,
            <given-names>T.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Smith</surname>
            ,
            <given-names>M.C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Good</surname>
            ,
            <given-names>G.S.</given-names>
          </string-name>
          : Understanding and
          <string-name>
            <surname>Deploying LDAP Directory</surname>
          </string-name>
          <article-title>Services</article-title>
          . Second edn.
          <source>Macmillan Network Architecture and Development Series. Macmillan Technical Publishing</source>
          (
          <year>2003</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Lassila</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Swick</surname>
            ,
            <given-names>R.R.</given-names>
          </string-name>
          :
          <article-title>Resource Description Framework (RDF) Model and Syntax Specification</article-title>
          .
          <source>W3C Recommendation, World Wide Web Consortium (W3C)</source>
          (
          <year>1999</year>
          ) http://www.w3.org/TR/1999/REC-rdf-syntax-
          <volume>19990222</volume>
          /.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Bizer</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>RAP (RDF API for PHP)</article-title>
          .
          <source>Website</source>
          (
          <year>2004</year>
          ) http://www.wiwiss.fuberlin.de/suhl/bizer/rdfapi/.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Mealling</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>A URN Namespace of Object Identifiers</article-title>
          .
          <source>RFC 3061</source>
          ,
          <article-title>The Internet Engineering Task Force (IETF) (</article-title>
          <year>2001</year>
          ) http://www.ietf.org/rfc/rfc3061.txt.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>