本節介紹可用的規則類型、它們在 Identity Manager 中的角色,以及如何定義您自己的規則。 涵蓋的主題如下:
您可以在「訂閱者」和「發行者」通道上定義數種不同的規則類型。 每個規則會在不同的資料轉換步驟中套用,而有些規則只有在特定動作出現時才會套用。 例如,「建立」規則只有在建立新物件時才會套用。
規則在通道上的執行順序是:
圖 1-1 規則的執行順序

「事件轉換」規則會改變 Metadirectory 引擎對於 Identity Vault 或已連接應用程式中發生的事件之檢視方式。 「事件轉換」規則中最常執行的任務是自定過濾,例如範圍過濾和事件類型過濾。
範圍過濾會根據事件位置或屬性值,移除不想要的事件。 比方說,如果部門屬性不等於特定的值或不是特定群組的成員,就將事件移除。
事件類型過濾會根據事件類型,移除不想要的事件。 例如,移除所有刪除事件。
範例:
範圍過濾: 此範例「DirXML 程序檔」規則只讓下列使用者的事件通過:包含在「使用者」子網路樹中、未被停用,且在 Title 屬性中不包含 Consultant 或 Manager 一字。 它也會產生一個狀態文件,指出操作被封鎖的時間。
<policy>
<rule>
<description>Scope Filtering</description>
<conditions>
<or>
<if-class-name op="equal">User</if-class-name>
</or>
<or>
<if-src-dn op="not-in-subtree">Users</if-src-dn>
<if-attr name="Login Disabled" op="equal">True</if-attr>
<if-attr mode="regex" name="Title" op="equal">.*Consultant.*</if-attr>
<if-attr mode="regex" name="Title" op="equal">.*Manager.*</if-attr>
</or>
</conditions>
<actions>
<do-status level="error">
<arg-string>
<token-text>User doesn’t meet required conditions</token-text>
</arg-string>
</do-status>
<do-veto/>
</actions>
</rule>
</policy>
此「DirXML 程序檔」規則允許在「使用者」物件上進行修改操作,但是不能修改已相關聯的物件。
<policy>
<rule>
<description>Veto all operation on User except modifies of already associated objects</description>
<conditions>
<or>
<if-class-name op="equal">User</if-class-name>
</or>
<or>
<if-operation op="not-equal">modify</if-operation>
<if-association op="not-associated"/>
</or>
</conditions>
<actions>
<do-veto/>
</actions>
</rule>
</policy>
類型過濾 - 此「DirXML 程序檔」規則 (Policy) 的第一個規則 (Rule) 只允許同步化 Employee 和 Contractor 容器中的物件。 第二個規則 (Rule) 阻擋了所有「重新命名」和「移動」操作。
<policy>
<rule>
<description>Only synchronize the Employee and Contractor subtrees</description>
<conditions>
<and>
<if-src-dn op="not-in-container">Employees</if-src-dn>
<if-src-dn op="not-in-container">Contractors</if-src-dn>
</and>
</conditions>
<actions>
<do-status level="warning">
<arg-string>
<token-text>Change ignored: Out of scope.</token-text>
</arg-string>
</do-status>
<do-veto/>
</actions>
</rule>
<rule>
<description>Don’t synchronize moves or renames</description>
<conditions>
<or>
<if-operation op="equal">move</if-operation>
<if-operation op="equal">rename</if-operation>
</or>
</conditions>
<actions>
<do-status level="warning">
<arg-string>
<token-text>Change ignored: We don’t like you to do that.</token-text>
</arg-string>
</do-status>
<do-veto/>
</actions>
</rule>
</policy>
此「DirXML 程序檔」規則會封鎖所有「新增」事件。
<policy>
<rule>
<description>Type Filtering</description>
<conditions>
<and>
<if-operation op="equal">add</if-operation>
</and>
</conditions>
<actions>
<do-status level="warning">
<arg-string>
<token-text>Change ignored: Adds are not allowed.</token-text>
</arg-string>
</do-status>
<do-veto/>
</actions>
</rule>
</policy>
「相符」規則 (例如「訂閱者相符」和「發行者相符」) 會在目的資料儲存內,尋找與來源資料儲存中未關聯物件對應的物件。 請務必注意,「相符」規則並非一定需要。
例如,以下情況可能就不需要「相符」規則:
「相符」規則必須小心制訂,確保「相符」規則不會找到不正確的相符項目。
範例:
依據 ID 比對: 此範例「DirXML 程序檔」規則會依據 Internet Email Address 比對使用者。
<policy>
<rule>
<description>Match Users based on email address</description>
<conditions>
<and>
<if-class-name op="equal">User</if-class-name>
</and>
</conditions>
<actions>
<do-find-matching-object>
<arg-dn>
<token-text>ou=people,o=novell</token-text>
</arg-dn>
<arg-match-attr name="Internet EMail Address"/>
</do-find-matching-object>
</actions>
</rule>
</policy>
依據名稱比對: 此範例「DirXML 程序檔」規則會依據其 Common Name 屬性比對「群組」物件。
<?xml version="1.0" encoding="UTF-8"?>
<policy>
<rule>
<description>Match Group by Common Name</description>
<conditions>
<or>
<if-class-name op="equal">Group</if-class-name>
</or>
</conditions>
<actions>
<do-find-matching-object scope="subtree">
<arg-match-attr name="CN"/>
</do-find-matching-object>
</actions>
</rule>
</policy>
「建立」規則 (例如「訂閱者建立」規則和「發行者建立」規則」) 定義了建立新物件必須符合的條件。 沒有「建立」規則表示可以建立物件。
例如,您在 Identity Vault 中建立新使用者,但是您只提供名稱和 ID 給新的「使用者」物件。 此建立動作會在 eDirectory 網路樹中鏡像複製,但是由於您有一個「建立」規則,指定只允許有更完整定義的「使用者」物件,所以此新增不會立即反應在已連接至 Identity Vault 的應用程式。
「發行者」通道和「訂閱者」通道的「建立」規則可以相同,也可以不同。
要在 eDirectory 中建立物件時,可以指定要在建立程序中使用「範本」物件。
「建立」規則常用來進行以下動作:
範例:
必要屬性: 此範例「DirXML 程序檔」規則 (Policy) 的第一個規則 (Rule) 要求「使用者」物件需包含 CN、Given Name、Surname 和 Internet EMail Address 屬性,才能建立使用者。 第二個規則 (Rule) 要求所有「組織單位」物件都要有 OU 屬性。 最後一個規則 (Rule) 否決了所有名稱為 Fred 的「使用者」物件。
<policy>
<rule>
<description>Veto if required attributes CN, Given Name, Surname and Internet EMail Address not available</description>
<conditions>
<or>
<if-class-name op="equal">User</if-class-name>
</or>
</conditions>
<actions>
<do-veto-if-op-attr-not-available name="CN"/>
<do-veto-if-op-attr-not-available name="Given Name"/>
<do-veto-if-op-attr-not-available name="Surname"/>
<do-veto-if-op-attr-not-available name="Internet EMail Address"/>
</actions>
</rule>
<rule>
<description>Organizational Unit Required Attributes</description>
<conditions>
<or>
<if-class-name op="equal">Organizational Unit</if-class-name>
</or>
</conditions>
<actions>
<do-veto-if-op-attr-not-available name="OU"/>
</actions>
</rule>
</policy>
預設的屬性值: 此範例「DirXML 程序檔」規則會為使用者的 Description 屬性加入預設值。
<policy>
<rule>
<description>Default Description of New Employee</description>
<conditions>
<or>
<if-class-name op="equal">User</if-class-name>
</or>
</conditions>
<actions>
<do-set-default-attr-value name="Description">
<arg-value type="string">
<token-text>New Employee</token-text>
</arg-value>
</do-set-default-attr-value>
</actions>
</rule>
</policy>
預設的密碼: 此範例「DirXML 程序檔」規則提供密碼值的建立,密碼值是以名字的前兩個字元和姓氏的前六個字元組成,均為小寫。
<policy>
<rule>
<description>Default Password of [2]FN+[6]LN</description>
<conditions>
<and>
<if-class-name op="equal">User</if-class-name>
<if-password op="not-available"/>
</and>
</conditions>
<actions>
<do-set-dest-password>
<arg-string>
<token-lower-case>
<token-substring length="2">
<token-op-attr name="Given Name"/>
</token-substring>
<token-substring length="6">
<token-op-attr name="Surname"/>
</token-substring>
</token-lower-case>
</arg-string>
</do-set-dest-password>
</actions>
</rule>
</policy>
指定範本: 如果使用者的 Title 屬性指出使用者是 Manager (包含 "Manager"),此範例「DirXML 程序檔」規則會指定一個範本物件。
<policy>
<rule>
<description>Assign Manager Template if Title contains Manager</description>
<conditions>
<and>
<if-class-name op="equal">User</if-class-name>
<if-op-attr name="Title" op="available"/>
<if-op-attr mode="regex" name="Title" op="equal">.*Manager.*</if-op-attr>
</and>
</conditions>
<actions>
<do-set-op-template-dn>
<arg-dn>
<token-text>Users\Manager Template</token-text>
</arg-dn>
</do-set-op-template-dn>
</actions>
</rule>
</policy>
「佈置」規則用來決定新物件要放在哪裡,以及它們在 Identity Vault 和已連接應用程式中的名稱。
如果您要在 Identity Vault 中進行物件建立,則「發行者」通道上必須要有「佈置」規則。 即使您要在已連接應用程式中進行物件建立,「訂閱者」通道上也不一定要有「佈置」規則,要看目的資料儲存的本質而定。 例如,由於關聯式資料庫中的列沒有位置或名稱,所以當同步化關聯式資料庫時,就不需要「佈置」規則。
範例:
依屬性值佈置: 此範例「DirXML 程序檔」規則會根據 Department 屬性的值,將「使用者」建立在特定的容器中。
<policy>
<rule>
<description>Department Engineering</description>
<conditions>
<and>
<if-class-name op="equal">User</if-class-name>
<if-op-attr mode="regex" name="Department" op="equal">.*Engineering.*</if-op-attr>
</and>
</conditions>
<actions>
<do-set-op-dest-dn>
<arg-dn>
<token-text>Eng</token-text>
<token-text>\</token-text>
<token-op-attr name="CN"/>
</arg-dn>
</do-set-op-dest-dn>
</actions>
</rule>
<rule>
<description>Department HR</description>
<conditions>
<and>
<if-class-name op="equal">User</if-class-name>
<if-op-attr mode="regex" name="Department" op="equal">.*HR.*</if-op-attr>
</and>
</conditions>
<actions>
<do-set-op-dest-dn>
<arg-dn>
<token-text>HR</token-text>
<token-text>\</token-text>
<token-op-attr name="CN"/>
</arg-dn>
</do-set-op-dest-dn>
</actions>
</rule>
</policy>
此範例「DirXML 程序檔」規則會根據輸入文件中的 src-dn 來決定「使用者」或「組織單位」的位置。
<policy>
<rule>
<description>PublisherPlacementRule</description>
<conditions>
<or>
<if-class-name op="equal">User</if-class-name>
<if-class-name op="equal">Organizational Unit</if-class-name>
</or>
<or>
<if-src-dn op="in-subtree">o=people, o=novell</if-src-dn>
</or>
</conditions>
<actions>
<do-set-op-dest-dn>
<arg-dn>
<token-text>People</token-text>
<token-text>\</token-text>
<token-unmatched-src-dn convert="true"/>
</arg-dn>
</do-set-op-dest-dn>
</actions>
</rule>
</policy>
依名稱佈置: 此範例「DirXML 程序檔」規則會根據使用者姓氏的第一個字母,將使用者建立在特定的容器中。 使用者的姓氏以 A 到 I 開頭者,會放在容器 Users1 中,而姓氏開頭為 J 到 R 的使用者,則會放在 Users2 中,S 到 Z 則放在 Users3 中。
<policy>
<rule>
<description>Surname - A to I in Users1</description>
<conditions>
<and>
<if-class-name op="equal">User</if-class-name>
<if-op-attr mode="regex" name="Surname" op="equal">[A-I].*</if-op-attr>
</and>
</conditions>
<actions>
<do-set-op-dest-dn>
<arg-dn>
<token-text>Users1</token-text>
<token-text>\</token-text>
<token-op-attr name="CN"/>
</arg-dn>
</do-set-op-dest-dn>
</actions>
</rule>
<rule>
<description>Surname - J to R in Users2</description>
<conditions>
<and>
<if-class-name op="equal">User</if-class-name>
<if-op-attr mode="regex" name="Surname" op="equal">[J-R].*</if-op-attr>
</and>
</conditions>
<actions>
<do-set-op-dest-dn>
<arg-dn>
<token-text>Users2</token-text>
<token-text>\</token-text>
<token-op-attr name="CN"/>
</arg-dn>
</do-set-op-dest-dn>
</actions>
</rule>
<rule>
<description>Surname - S to Z in Users3</description>
<conditions>
<and>
<if-class-name op="equal">User</if-class-name>
<if-op-attr mode="regex" name="Surname" op="equal">[S-Z].*</if-op-attr>
</and>
</conditions>
<actions>
<do-set-op-dest-dn>
<arg-dn>
<token-text>Users3</token-text>
<token-text>\</token-text>
<token-op-attr name="CN"/>
</arg-dn>
</do-set-op-dest-dn>
</actions>
</rule>
</policy>
「指令轉換」規則會以替代或加入指令的方式,改變 Identity Manager 正在傳送至目的資料儲存的指令。 「指令轉換」規則中替代指令的一個例子是:攔截「刪除」指令,並以「修改」、「移動」或「停用」指令來取代。 而「指令轉換」規則中加入指令的常見例子,則是根據「新增」指令的屬性值來建立「修改」指令。
最籠統的說法是,「指令轉換」規則是用來將 Identity Manager 執行的指令,改變為提交至 Metadirectory 引擎之事件的預設處理結果。
將不完全符合所有其他規則描述的規則包含在內,也是常見的作法。
範例:
將「刪除」轉換為「修改」: 此「DirXML 程序檔」規則會將 Login Disabled 屬性的「刪除」操作轉換為「修改」操作。
<policy>
<rule>
<description>Convert User Delete to Modify</description>
<conditions>
<and>
<if-operation op="equal">delete</if-operation>
<if-class-name op="equal">User</if-class-name>
</and>
</conditions>
<actions>
<do-set-dest-attr-value name="Login Disabled">
<arg-value type="state">
<token-text>true</token-text>
</arg-value>
</do-set-dest-attr-value>
<do-veto/>
</actions>
</rule>
</policy>
建立其他操作: 此「DirXML 程序檔」規則會判斷使用者的目的容器是否已存在。 如果容器不存在,規則便會建立「新增」操作,以便建立「容器」物件。
<policy>
<rule>
<description>Check if destination container already exists</description>
<conditions>
<and>
<if-operation op="equal">add</if-operation>
</and>
</conditions>
<actions>
<do-set-local-variable name="target-container">
<arg-string>
<token-dest-dn length="-2"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="does-target-exist">
<arg-string>
<token-dest-attr class-name="OrganizationalUnit" name="objectclass">
<arg-dn>
<token-local-variable name="target-container"/>
</arg-dn>
</token-dest-attr>
</arg-string>
</do-set-local-variable>
</actions>
</rule>
<rule>
<description>Create the target container if necessary</description>
<conditions>
<and>
<if-local-variable name="does-target-exist" op="available"/>
<if-local-variable name="does-target-exist" op="equal"/>
</and>
</conditions>
<actions>
<do-add-dest-object class-name="organizationalUnit" direct="true">
<arg-dn>
<token-local-variable name="target-container"/>
</arg-dn>
</do-add-dest-object>
<do-add-dest-attr-value direct="true" name="ou">
<arg-dn>
<token-local-variable name="target-container"/>
</arg-dn>
<arg-value type="string">
<token-parse-dn dest-dn-format="dot" length="1" src-dn-format="dest-dn" start="-1">
<token-local-variable name="target-container"/>
</token-parse-dn>
</arg-value>
</do-add-dest-attr-value>
</actions>
</rule>
</policy>
設定密碼過期時間: 此「DirXML 程序檔」規則會修改 eDirectory 使用者的 Password Expiration Time 屬性。
<?xml version="1.0" encoding="UTF-8"?>
<policy xmlns:jsystem="http://www.novell.com/nxsl/java/java.lang.System">
<rule>
<description>Set password expiration time for a given interval from current day</description>
<conditions>
<and>
<if-operation op="equal">modify-password</if-operation>
</and>
</conditions>
<actions>
<do-set-local-variable name="interval">
<arg-string>
<token-text>30</token-text>
</arg-string>
</do-set-local-variable>
<do-set-dest-attr-value class-name="User" name="Password Expiration Time" when="after">
<arg-association>
<token-association/>
</arg-association>
<arg-value type="string">
<token-xpath expression="round(jsystem:currentTimeMillis() div 1000 + (86400*$interval))"/>
</arg-value>
</do-set-dest-attr-value>
</actions>
</rule>
</policy>
「綱要映射」規則會保留 Identity Vault 和已連接系統之間的綱要映射定義。
Identity Vault 綱要會從 eDirectory 讀取。 已連接系統的 Identity Manager 驅動程式會提供已連接應用程式的綱要。 在識別出兩個綱要後,Identity Vault 和目標應用程式之間便會建立簡易映射。
在 Identity Manager 驅動程式組態中定義了「綱要映射」規則後,便可映射對應的資料。
請務必注意以下事項:
如需管理資訊,請參閱節 7.0, 管理綱要映射規則。
範例:
基本綱要映射規則: 此範例「DirXML 程序檔」規則會顯示基本「綱要映射」規則的原始 XML 來源。 不過,當您透過 Designer for Identity Manager 編輯規則時,預設「綱要映射」編輯器便可讓規則以圖形化的方式顯示和編輯。
<?xml version="1.0" encoding="UTF-8"?><attr-name-map>
<class-name>
<app-name>WorkOrder</app-name>
<nds-name>DirXML-nwoWorkOrder</nds-name>
</class-name>
<class-name>
<app-name>PbxSite</app-name>
<nds-name>DirXML-pbxSite</nds-name>
</class-name>
<attr-name class-name="DirXML-pbxSite">
<app-name>PBXName</app-name>
<nds-name>DirXML-pbxName</nds-name>
</attr-name>
<attr-name class-name="DirXML-pbxSite">
<app-name>TelephoneNumber</app-name>
<nds-name>Telephone Number</nds-name>
</attr-name>
<attr-name class-name="DirXML-pbxSite">
<app-name>LoginName</app-name>
<nds-name>DirXML-pbxLoginName</nds-name>
</attr-name>
<attr-name class-name="DirXML-pbxSite">
<app-name>Password</app-name>
<nds-name>DirXML-pbxPassword</nds-name>
</attr-name>
<attr-name class-name="DirXML-pbxSite">
<app-name>Nodes</app-name>
<nds-name>DirXML-pbxNodesNew</nds-name>
</attr-name>
</attr-name-map>
自定綱要映射規則: 此範例「DirXML 程序檔」規則會使用「DirXML 程序檔」執行自定「綱要映射」。
<?xml version="1.0" encoding="UTF-8"?><policy>
<rule>
<!--
The Schema Mapping Policy can only handle one-to-one mappings.
That Mapping Policy maps StudentPersonal addresses.
This rule maps StaffPersonal addresses.
-->
<description>Publisher Staff Address Mappings</description>
<conditions>
<and>
<if-local-variable name="fromNds" op="equal">false</if-local-variable>
<if-xpath op="true">@original-class-name = ’StaffPersonal’</if-xpath>
</and>
</conditions>
<actions>
<do-rename-op-attr dest-name="SA" src-name="Address/Street/Line1"/>
<do-rename-op-attr dest-name="Postal Office Box" src-name="Address/Street/Line2"/>
<do-rename-op-attr dest-name="Physical Delivery Office Name" src-name="Address/City"/>
<do-rename-op-attr dest-name="S" src-name="Address/StatePr"/>
<do-rename-op-attr dest-name="Postal Code" src-name="Address/PostalCode"/>
</actions>
</rule>
<rule>
<description>Subscriber Staff Address Mappings</description>
<!--
The Schema Mapping Policy has already mapped addresses to StudentPersonal.
This rule maps StudentPersonal to StaffPersonal.
-->
<conditions>
<and>
<if-local-variable name="fromNds" op="equal">true</if-local-variable>
<if-op-attr name="DirXML-sifIsStaff" op="equal">true</if-op-attr>
</and>
</conditions>
<actions>
<do-rename-op-attr dest-name="Address/Street/Line1" src-name="StudentAddress/Address/Street/Line1"/>
<do-rename-op-attr dest-name="Address/Street/Line2" src-name="StudentAddress/Address/Street/Line2"/>
<do-rename-op-attr dest-name="Address/City" src-name="StudentAddress/Address/City"/>
<do-rename-op-attr dest-name="Address/StatePr" src-name="StudentAddress/Address/StatePr"/>
<do-rename-op-attr dest-name="Address/PostalCode" src-name="StudentAddress/Address/PostalCode"/>
</actions>
</rule>
</policy>
「輸出轉換」規則主要處理由 Metadirectory 引擎提供的資料到應用程式 Shim 所需的資料之間,一種資料格式上的轉換。 這些轉換的範例包含:
Metadirectory 引擎在任一通道上提供給應用程式 Shim 的所有文件,都會透過「輸出轉換」規則傳遞。 由於「輸出轉換」發生於綱要映射之後,因此所有的綱要名稱都會在應用程式名稱空間內。
範例:
屬性值的轉換 此範例「DirXML 程序檔」規則會將電話號碼由 (nnn) nnn-nnnn 格式,重新格式化為 nnn.nnn.nnnn 格式。 您可以在「輸入轉換」規則範例中找到反向轉換。
<policy>
<rule>
<description>Reformat all telephone numbers from (nnn) nnn-nnnn to nnn.nnn.nnnn</description>
<conditions/>
<actions>
<do-reformat-op-attr name="telephoneNumber">
<arg-value type="string">
<token-replace-first regex="^\((\d\d\d)\) *(\d\d\d)-(\d\d\d\d)$" replace-with="$1.$2.$3">
<token-local-variable name="current-value"/>
</token-replace-first>
</arg-value>
</do-reformat-op-attr>
</actions>
</rule>
</policy>
自定處理狀態訊息: 此範例「DirXML 程序檔」規則會偵測層級不等於 success,且又包含操作資料內之子代 password-publish-status 元素的狀態文件,然後再使用 DoSendEmailFromTemplate 動作產生電子郵件訊息。
<?xml version="1.0" encoding="UTF-8"?>
<policy>
<description>Email notifications for failed password publications</description>
<rule>
<description>Send e-mail for a failed publish password operation</description>
<conditions>
<and>
<if-global-variable mode="nocase" name="notify-user-on-password-dist-failure" op="equal">true</if-global-variable>
<if-operation op="equal">status</if-operation>
<if-xpath op="true">self::status[@level != ’success’]/operation-data/password-publish-status</if-xpath>
</and>
</conditions>
<actions>
<!-- generate email notification -->
<do-send-email-from-template notification-dn="\cn=security\cn=Default Notification Collection" template-dn="\cn=security\cn=Default Notification Collection\cn=Password Sync Fail">
<arg-string name="UserFullName">
<token-src-attr name="Full Name">
<arg-association>
<token-xpath expression="self::status/operation-data/password-publish-status/association"/>
</arg-association>
</token-src-attr>
</arg-string>
<arg-string name="UserGivenName">
<token-src-attr name="Given Name">
<arg-association>
<token-xpath expression="self::status/operation-data/password-publish-status/association"/>
</arg-association>
</token-src-attr>
</arg-string>
<arg-string name="UserLastName">
<token-src-attr name="Surname">
<arg-association>
<token-xpath expression="self::status/operation-data/password-publish-status/association"/>
</arg-association>
</token-src-attr>
</arg-string>
<arg-string name="ConnectedSystemName">
<token-global-variable name="ConnectedSystemName"/>
</arg-string>
<arg-string name="to">
<token-src-attr name="Internet Email Address">
<arg-association>
<token-xpath expression="self::status/operation-data/password-publish-status/association"/>
</arg-association>
</token-src-attr>
</arg-string>
<arg-string name="FailureReason">
<token-text/>
<token-xpath expression="self::status/child::text()"/>
</arg-string>
</do-send-email-from-template>
</actions>
</rule>
</policy>
「輸入轉換」規則主要處理由應用程式 Shim 提供給 Metadirectory 引擎所需的資料之間,一種資料格式上的轉換。 這些轉換的範例包括:
應用程式 Shim 在任一通道上提供給 Metadirectory 引擎的所有文件,都會透過「輸入轉換」規則傳遞。
範例:
屬性值的格式轉換: 此範例「DirXML 程序檔」規則會將電話號碼由 nnn.nnn.nnnn 格式,重新格式化為 (nnn) nnn-nnnn 格式。 您可以在「輸出轉換」規則範例中找到反向轉換。
<policy>
<rule>
<description>Reformat all telephone numbers from nnn.nnn.nnnn to (nnn) nnn-nnnn</description>
<conditions/>
<actions>
<do-reformat-op-attr name="telephoneNumber">
<arg-value type="string">
<token-replace-first regex="^(\d\d\d)\.(\d\d\d)\.(\d\d\d\d)$" replace-with="($1) $2-$3">
<token-local-variable name="current-value"/>
</token-replace-first>
</arg-value>
</do-reformat-op-attr>
</actions>
</rule>
</policy>
驅動程式活動訊號: 此「DirXML 程序檔」規則會建立狀態活動訊號事件。 驅動程式的活動訊號功能用於在每個活動訊號間隔之間傳送成功訊息 (HEARTBEAT: $driver)。 該訊息可由 Novell Audit 監看。Identity Manager 必須支援活動訊號,且必須在驅動程式組態頁面上啟用活動訊號。
<?xml version="1.0" encoding="UTF-8" ?>
<policy>
<rule>
<description>Heartbeat Rule, v1.01, 040126, by Holger Dopp</description>
<conditions>
<and>
<if-operation op="equal">status</if-operation>
<if-xpath op="true">@type="heartbeat"</if-xpath>
</and>
</conditions>
<actions>
<do-set-xml-attr expression="." name="text1">
<arg-string>
<token-global-variable name="dirxml.auto.driverdn" />
</arg-string>
</do-set-xml-attr>
<do-set-xml-attr expression="." name="text2">
<arg-string>
<token-text>HEARTBEAT</token-text>
</arg-string>
</do-set-xml-attr>
</actions>
</rule>
</policy>
所有規則會以兩種方式之一定義:
「綱要映射」規則也可以使用綱要映射表格加以定義 (通常也是如此)。
「規則產生器」介面用於定義您可能會實作的大部份規則。 「規則產生器」介面使用圖形化環境,讓您可以輕鬆地定義並管理規則。
在「規則產生器」中,建立規則的基本功能是由稱為「DirXML 程序檔」的自定指令碼語言所提供。
「DirXML 程序檔」包含各種您可以測試的條件,用於執行的動作,以及要新增至規則的動態值。 這些選項中的每一項都會透過智慧型的下拉式清單呈現,並且只提供您每一處的有效選項,以及常見值的快速連結。
「規則產生器」則可讓您不需要直接使用「DirXML 程序檔」。
如需「規則產生器」的相關資訊,請參閱節 2.0, 搭配 Designer 使用規則產生器定義規則和節 3.0, 使用 iManager 內的規則產生器定義規則。 如需「DirXML 程序檔」的相關資訊,請參閱節 1.1.2, DirXML 程序檔。
提示:就使用「規則產生器」而言雖然沒有必要,但您還是可以到「DirXML 驅動程式開發人員套件文件」網站取得完整的「DirXML 程序檔」參考資訊。
若要定義更多的複雜規則,可使用 XSLT 樣式表將某 XML 文件直接轉換為包含所需變更的另一個 XML 文件。
樣式表提供您大幅度的彈性。若轉換的動作不符合「規則產生器」中使用規則建立的可用預先定義條件和動作,此時便可使用樣式表。
若要建立 XSLT 樣式表,您便需要徹底瞭解 XSLT、nds.dtd,以及進出於 Metadirectory 引擎的指令和事件。 如需詳細的 nds.dtd 參考,請參閱「NDS DTD 參考」
如需 XSLT 樣式表的相關資訊,請參閱節 5.0, 使用 XSLT 樣式表定義規則。
Novell 已提供可以下載並用於您環境中的範例規則。 Novell 的支援網站中有這些規則可供使用 下載檔案並加以擷取。 How_To_Install.rtf 檔包含了安裝指示。
若要使用 Designer 輸入檔案,請參閱從 XML 檔案輸入規則。 若要使用 iManager 輸入檔案,請參閱節 3.2.9, 從 XML 檔案輸入規則。