Extracting a Second Entry in a Multi-Valued Attribute
Novell Cool Solutions: Tip
Digg This -
Posted: 1 Aug 2007
A Forum reader recently asked:
"For a long time I have used the "Other Name", which is second entry of a multi-valued CN for storing a Student number. Now I want to move it to a separate attribute. I tried an IDM 3.5 loopback driver, but I cannot fetch the second attribute. I always get back the naming part of the CN attribute. Any ideas?"
And here's the response from Father Ramon ...
You haven't said how you are trying to get the attribute, but typically you would get back all values. However, if you were trying to use it as a single value, you would get whichever was the first one to be returned, which may or may not be the naming value. The easiest way to distinguish between the two is that the value element for the naming value will have naming="true" attribute attached to it. So, something like the following would probably do what you want:
<rule> <description>non-naming cn</description> <conditions/> <actions> <do-set-local-variable name="cn" scope="policy"> <arg-node-set> <token-src-attr name="CN"/> </arg-node-set> </do-set-local-variable> <do-for-each> <arg-node-set> <token-xpath expression="$cn[not(@naming = 'true')]"/> </arg-node-set> <arg-actions> <do-set-src-attr-value name="newattr"> <arg-value> <token-local-variable name="current-node"/> </arg-value> </do-set-src-attr-value> <do-remove-src-attr-value name="CN"> <arg-value> <token-local-variable name="current-node"/> </arg-value> </do-remove-src-attr-value> </arg-actions> </do-for-each> </actions> </rule>
Aaron Burgemeister adds:
Why not get all values in that attribute and remove the one that is part of the DN? That would seem to be the easy way to find the naming attribute, regardless of its position. Perhaps you could use a "for-each" approach ...
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com