Various user objects in my tree have multiple values in the CN field. I
would like to strip out all but the first one. I tried setting CN to a
local variable then looping through the current-node's to see if I had
a multi-valued CN, but cannot figure out how to go back and actually
strip out all the extra names from my CN attribute w/out causing an
error message.

Code I am using to identity a multi-valued CN is here. I think I'm
close to what I need, but need a little push to get that CN stripping
piece put to rest.

The first part of the code with the HoldCN and StripCN identifies if we
have a mutli-valued CN by stringing all the values together (separated
by a %).

Then I test for a % and if I find one I know I have a mutli-valued CN
(sorry for the terminology, I realize CN by nature is multi-valued,
what I mean is I found that it has multiple values).

At that point I want to go back through the source CN and strip off all
but the first value I find. Iest in my loop for the first value by
setting a switch. First time thru the loop I turn the switch off.

I sort of died on pass 2 through however many I have not knowing how to
strip the value of my current node of source CN out.

<do-set-local-variable name="HoldCN">
<arg-node-set>
<token-src-attr name="CN"/>
</arg-node-set>
</do-set-local-variable>
<do-for-each>
<arg-node-set>
<token-local-variable name="HoldCN"/>
</arg-node-set>
<arg-actions>
<do-set-local-variable name="StripCN">
<arg-string>
<token-local-variable name="StripCN"/>
<token-text xml:space="preserve">%</token-text>
<token-local-variable name="current-node"/>
</arg-string>
</do-set-local-variable>
<do-trace-message color="white" level="4">
<arg-string>
<token-text xml:space="preserve">StripCN is now -></token-text>
<token-local-variable name="StripCN"/>
<token-text xml:space="preserve">&lt;</token-text>
<token-text xml:space="preserve"/>
</arg-string>
</do-trace-message>
</arg-actions>
</do-for-each>
<do-set-local-variable name="StripCN">
<arg-string>
<token-substring length="-2" start="1">
<token-local-variable name="StripCN"/>
</token-substring>
</arg-string>
</do-set-local-variable>
<do-if>
<arg-conditions>
<and>
<if-local-variable mode="regex" name="StripCN"
op="equal">.*%.*</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-trace-message color="white" level="4">
<arg-string>
<token-text xml:space="preserve">We found a mutli-valued
CN</token-text>
</arg-string>
</do-trace-message>
<do-set-src-attr-value disabled="true" name="CN">
<arg-value type="string">
<token-local-variable name="HoldCN"/>
</arg-value>
</do-set-src-attr-value>
<do-set-local-variable name="switch">
<arg-string>
<token-text xml:space="preserve">1</token-text>
</arg-string>
</do-set-local-variable>
<do-for-each>
<arg-node-set>
<token-src-attr name="CN"/>
</arg-node-set>
<arg-actions>
<do-if>
<arg-conditions>
<and>
<if-local-variable name="switch"
op="equal">1</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="switch">
<arg-string>
<token-text xml:space="preserve">0</token-text>
</arg-string>
</do-set-local-variable>
</arg-actions>
<arg-actions>
<do-strip-xpath expression="$current-node"/>
</arg-actions>
</do-if>
</arg-actions>
</do-for-each>
</arg-actions>
<arg-actions>
<do-trace-message color="white" level="4">
<arg-string>
<token-text xml:space="preserve">We DID NOT find a multi-valued
CN</token-text>
</arg-string>
</do-trace-message>
</arg-actions>
</do-if>
</actions>
</rule>
</policy>


--
johnehurst
------------------------------------------------------------------------
johnehurst's Profile: http://forums.novell.com/member.php?userid=1973
View this thread: http://forums.novell.com/showthread.php?t=339246