ODBC Driver for LDAP

Build 23.0.8839

LDAP テーブルとの連携

LDAP オブジェクトクラスへのテーブルスキーマのマッピングを定義する。

このセクションでは、Person.rsd ファイルを使ってCData ODBC Driver for LDAP において希望するオブジェクトクラスの新テーブルを作成する方法を説明します。Person.rsd は、本製品 のインストールフォルダのdb サブフォルダに格納されています。

カスタムスキーマを使用するには、Location プロパティをスキーマファイルを有するフォルダに設定します。スキーマを.rsd ファイルで定義する。

新しいテーブルを定義する

新しいテーブルを、そのテーブルが表すオブジェクトクラスと同じ名前に定義することは大切です。これにより、本製品 はLDAP サーバーをクエリする際に、ターゲットのオブジェクトクラスのみを検索します。

rsb:info エレメントでテーブル名を定義する。次の例では、Person.rsd のテーブル名およびカラムの定義について説明します:

<rsb:script xmlns:rsb="http://www.rssbus.com/ns/rsbscript/2">

  <rsb:info title="Person" description="Create, update, delete, and query person entries in LDAP.">
    <!-- Required Columns -->
    <attr name="Id"              xs:type="string"  readonly="true"  key="true"       desc="The index of the row, when 'splitDataByRow' is set for a column, combined with the full distinguished name." />
    ...

テーブルカラムおよびインプット

スキーマ内の"attr" タグは、テーブルのカラムを表します。これらは、希望するオブジェクトクラスを構成するアトリビュートに合致するはずです。

まず、オブジェクトクラスに関係なく、すべてのテーブルに含まれるカラムがあります:

    <!-- Required Columns -->
    <attr name="Id"          xs:type="string" readonly="true"  key="true"       desc="The index of the row, when 'splitDataByRow' is set for a column, combined with the full distinguished name." />
    <attr name="DN"          xs:type="string" readonly="true"  required="false" other:ldaptype="OID"               desc="The full distinguished name." />
    <attr name="RDN"         xs:type="string" readonly="true"  required="false" other:ldaptype="Directory String"  desc="The relative distinguished name."/>
    <attr name="BaseDN"      xs:type="string" readonly="true"  required="false" other:ldaptype="OID"               desc="The base distinguished name." />

必須カラムに加えて、希望するオブジェクトクラスからのアトリビュートが指定される必要があります。追加で、データがテーブルからどのように返されるかを規定するdataFormat を指定する必要があります。次に例を示します。

    <!-- Person Required Attributes -->
    <attr name="ObjectClass"                 other:dataFormat="splitDataByRow" xs:type="string" readonly="false" required="false"  other:ldaptype="OID" desc="The object class of the entry."/>
    <attr name="SN"                          other:dataFormat="delimitedData"  xs:type="string" readonly="false" required="false"  other:ldaptype="Directory String"           desc="The required attribute SN for the user object class."/>
    <attr name="CN"                          other:dataFormat="delimitedData"  xs:type="string" readonly="false" required="false"  other:ldaptype="Directory String"           desc="The required attribute CN for the user object class."/>

    <!-- Person Optional Attributes -->
    <attr name="UserPassword"                other:dataFormat="delimitedData"  xs:type="string" readonly="false" required="false"  other:ldaptype="Binary"                     desc="The optional attribute UserPassword for the user object class."/>
    <attr name="TelephoneNumber"             other:dataFormat="delimitedData"  xs:type="string" readonly="false" required="false"  other:ldaptype="Directory String"           desc="The optional attribute TelephoneNumber for the user object class."/>
    <attr name="SeeAlso"                     other:dataFormat="delimitedData"  xs:type="string" readonly="false" required="false"  other:ldaptype="DN"                         desc="The optional attribute SeeAlso for the user object class."/>
    <attr name="Description_1"               other:dataFormat="splitDataByCol" xs:type="string" readonly="false" required="false"  other:ldaptype="Directory String"           desc="The optional attribute Description for the user object class."/>
    <attr name="Description_2"               other:dataFormat="splitDataByCol" xs:type="string" readonly="false" required="false"  other:ldaptype="Directory String"           desc="The optional attribute Description for the user object class."/>
    <attr name="Description_3"               other:dataFormat="splitDataByCol" xs:type="string" readonly="false" required="false"  other:ldaptype="Directory String"           desc="The optional attribute Description for the user object class."/>

The other: dataFormat には3つのオプションがあります:

delimitedDataTable Setting にて定義された"区切り" により区切られた文字列として、複数のアトリビュートを返します。(デフォルトはセミコロンです。)
splitDataByRow同じDN に対する複数のアトリビュート値は、別々の行として扱われます。他のすべてのカラムはそのままプッシュされ、Id のインデックスは増分されます。(このように複数のカラムをプッシュすることは、結果セットを大きくしてパフォーマンスの問題を引き起こす可能性があります。)
splitDataByCol同じDN に対する複数のアトリビュート値は、カラム名の付属インデックスとともにプッシュされます。複数のカラムを定義して終わりに"_n" を付ける必要があります。例えば、ObjectClass_1、ObjectClass_2、ObjectClass_3 のようにします。このサンプルでは、3つを超える値がある場合、カラムが追加されない限り、テーブルでは残りの値は表示されません。

例えば、次のコードはObjectClass アトリビュートの異なる値をそれぞれの行に分割して、Description をそれぞれのカラムにします。カラム定義には、Description アトリビュートの複数のカラムが含まれることに注意してください。<attr> に対する、other dataFormat アトリビュートにも注意してください。

    ...
    <attr name="ObjectClass"     other:dataFormat="delimitedData" xs:type="string"  readonly="false" required="false" other:ldaptype="OID" desc="The object class of the entry."/>
    <attr name="SN"              other:dataFormat="delimitedData" xs:type="string"  readonly="false" required="false" other:ldaptype="Directory String"           desc="The surname of the person."/> 
    <attr name="CN"              other:dataFormat="delimitedData" xs:type="string"  readonly="false" required="false" other:ldaptype="Directory String"           desc="The common name of the person."/> 
    <attr name="UserPassword"    other:dataFormat="delimitedData" xs:type="string"  readonly="false" required="false" other:ldaptype="Binary"                     desc="The user password of the person."/>
    <attr name="TelephoneNumber" other:dataFormat="delimitedData" xs:type="string"  readonly="false" required="false" other:ldaptype="Directory String"           desc="The telephone number of the person."/>
    <attr name="SeeAlso"         other:dataFormat="delimitedData" xs:type="string"  readonly="false" required="false" other:ldaptype="DN"                         desc="The see-also distinguished name of the person."/>
    <attr name="Description_1"   other:dataFormat="delimitedData" xs:type="string"  readonly="false" required="false" other:ldaptype="Directory String"           desc="The description of the person."/>
    <attr name="Description_2"   other:dataFormat="delimitedData" xs:type="string"  readonly="false" required="false" other:ldaptype="Directory String"           desc="The description of the person."/>
    <attr name="Description_3"   other:dataFormat="delimitedData" xs:type="string"  readonly="false" required="false" other:ldaptype="Directory String"           desc="The description of the person."/>
    
  </rsb:info>
  
  <!-- Table Settings -->
  <rsb:set attr="delimiter" value=";"/>
  ...
サンプルの結果はこのようになります:

Id DN ObjectClass SN CN UserPasswordTelephoneNumberSeeAlsoDescription_1Description_2Description_3
1|CN=User1,DC=Test CN=User1,DC=Test Top TestSN User1 555-5555 A;B;C Desc1 Desc2 Desc3
2|CN=User1,DC=Test CN=User1,DC=Test User TestSN User1 555-5555 A;B;C Desc1 Desc2 Desc3

Note:デフォルトで、データはdelimitedData として返されます。

インプットのデータ形式に加え、エンコードも指定が可能です。現在、UTF8 エンコード、もしくはBASE64 エンコードでのデータの戻りがサポートされています。特定のエンコードでデータを取得したい場合には、'other:encoding' フィールドを、使いたいエンコードのアトリビュートに指定する必要があります。エンコードの指定がない場合、UTF8 がデフォルトです。

アトリビュートのエンコード指定の例:

    ...
    <attr name="ObjectClass"     other:dataFormat="delimitedData" other:encoding="UTF8"   xs:type="string"  readonly="false" required="false" other:ldaptype="OID"               desc="The object class of the entry."/>
    <attr name="SN"              other:dataFormat="delimitedData" other:encoding="BASE64" xs:type="string"  readonly="false" required="false" other:ldaptype="Directory String"  desc="The surname of the person."/> 
    ...

テーブル設定

アトリビュートおよびインプットに加えて、区切り記号を指定する必要があります。

区切り記号(Delimiter)は、区切りデータで使われる文字です。区切りデータは、一つのオブジェクトに複数回出現するアトリビュートすべてにおいて返されます(他のdataFormat に指定されている場合を除いて)。

例えば、下のコードは';' 記号を使って、アトリビュートの複数の値をコンカテネイトします。

    ...
  </rsb:info>  
    
  <!-- Table Settings -->
  <rsb:set attr="delimiter" value=";"/>
  ...

オペレーション定義

オペレーション定義は、すべての新たに作られたテーブルにおいてそのまま維持されます。既存テーブルからコピー&ペーストしてください。
  <!-- Operation definitions -->
  <rsb:script method="GET">
    <rsb:set attr="action" value="Get" />
    <rsb:call op="ldapadoLDAP" >
      <rsb:push />
    </rsb:call>
  </rsb:script>

  <rsb:script method="POST">
    <rsb:set attr="action" value="Post" />
    <rsb:call op="ldapadoLDAP" >
      <rsb:push item="toout"/>
    </rsb:call>
  </rsb:script>

  <rsb:script method="MERGE">
    <rsb:set attr="action" value="Merge" />
    <rsb:call op="ldapadoLDAP" >
      <rsb:push />
    </rsb:call>
  </rsb:script>

  <rsb:script method="DELETE">
    <rsb:set attr="action" value="Delete" />
    <rsb:call op="ldapadoLDAP" >
      <rsb:push />
    </rsb:call>
  </rsb:script>

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839