ALERT! The community will be read-only starting on April 19, 8am Pacific as the migration begins. Read more for important details.
ALERT! The community will be read-only starting on April 19, 8am Pacific as the migration begins.Read more for important details.
Commodore
Commodore
1262 views

How to create a Cross Reference for an object in eDirectory

How to create a Cross Reference for an object in eDirectory

Labels (1)
13 Replies
Knowledge Partner Knowledge Partner
Knowledge Partner

When it comes to delete I think eDirectory will tidy that up automatically.
Commander
Commander

I did something like this some time ago. We needed to link users to departments and we needed it to point both ways, i.e. if a user points to a department then the department should automatically get a pointer to the user and the other way around.

I tried fiddling around with reciprocal attributes but I couldn't get it to work. Instead I created a policy in a null/loopback driver. It automatically keeps both attributes updated when adding/removing on either object. If they are already populated you need to do some kind of migration to get them synced first.

Deletes were not an issue since dn attributes are removed when the target is deleted.

<rule>
<description>Update attribute2 on the department when attribute1 changes on the user</description>
<conditions>
<and>
<if-class-name mode="nocase" op="equal">User</if-class-name>
<if-op-attr name="attribute1" op="changing"/>
<if-src-dn op="in-subtree">~USERSCONTAINER~</if-src-dn>
</and>
</conditions>
<actions>
<do-set-local-variable name="userDN" scope="policy">
<arg-string>
<token-src-dn/>
</arg-string>
</do-set-local-variable>
<do-for-each>
<arg-node-set>
<token-op-attr name="attribute1"/>
</arg-node-set>
<arg-actions>
<do-add-src-attr-value class-name="Group" name="attribute2">
<arg-dn>
<token-xpath expression="$current-node"/>
</arg-dn>
<arg-value type="dn">
<token-local-variable name="userDN"/>
</arg-value>
</do-add-src-attr-value>
</arg-actions>
</do-for-each>
<do-for-each>
<arg-node-set>
<token-removed-attr name="attribute1"/>
</arg-node-set>
<arg-actions>
<do-remove-src-attr-value class-name="Group" name="attribute2">
<arg-dn>
<token-xpath expression="$current-node"/>
</arg-dn>
<arg-value type="dn">
<token-local-variable name="userDN"/>
</arg-value>
</do-remove-src-attr-value>
</arg-actions>
</do-for-each>
</actions>
</rule>
<rule>
<description>Update attribute1  on the user when attribute2 changes on the department</description>
<conditions>
<and>
<if-class-name mode="nocase" op="equal">Group</if-class-name>
<if-op-attr name="attribute2" op="changing"/>
<if-src-dn op="in-subtree">~unitScope~</if-src-dn>
</and>
</conditions>
<actions>
<do-set-local-variable name="departmentDN" scope="policy">
<arg-string>
<token-src-dn/>
</arg-string>
</do-set-local-variable>
<do-for-each>
<arg-node-set>
<token-op-attr name="attribute2"/>
</arg-node-set>
<arg-actions>
<do-add-src-attr-value class-name="User" name="attribute1">
<arg-dn>
<token-xpath expression="$current-node"/>
</arg-dn>
<arg-value type="dn">
<token-local-variable name="departmentDN"/>
</arg-value>
</do-add-src-attr-value>
</arg-actions>
</do-for-each>
<do-for-each>
<arg-node-set>
<token-removed-attr name="attribute2"/>
</arg-node-set>
<arg-actions>
<do-remove-src-attr-value class-name="User" name="attribute1">
<arg-dn>
<token-xpath expression="$current-node"/>
</arg-dn>
<arg-value type="dn">
<token-local-variable name="departmentDN"/>
</arg-value>
</do-remove-src-attr-value>
</arg-actions>
</do-for-each>
</actions>
</rule>

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.