Article
Problem
A Forum reader recently asked:
"I have a eDirectory Container with 1000's of Groups. I have a RegEx String to match - *Marketing-Man.* - with the GroupName in that eDirectory Container in order to get the DN for a matched Group.
I want to traverse all the Groups in a specified eDirectory Container one by one, and perform a RegEx match operation on the current Group."
And here is the response from Father Ramon ...
Solution
If your regular expression is a simple one, you could just do a query on CN using wildcard character "*" and then loop on it. For example:
<do-for-each>
<arg-node-set>
<token-query class-name="Group" datastore="src" scope="subordinates">
<arg-dn>
<token-text>org\mygroups</token-text>
</arg-dn>
<arg-match-attr name="CN"/>
</token-query>
</arg-node-set>
<arg-actions>
<do-set-local-variable name="current-group-dn" scope="policy">
<arg-string>
<token-xpath expression="$current-node/@src-dn"/>
</arg-string>
</do-set-local-variable>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">Processing group: </token-text>
<token-local-variable name="current-group-dn"/>
</arg-string>
</do-trace-message>
</arg-actions>
</do-for-each>
If you really do need a real regular expression, then it is only slightly more complicated:
<do-for-each>
<arg-node-set>
<token-query class-name="Group" datastore="src" scope="subordinates">
<arg-dn>
<token-text>org\mygroups</token-text>
</arg-dn>
<arg-match-attr name="CN"/>
</token-query>
</arg-node-set>
<arg-actions>
<do-set-local-variable name="current-group-dn" scope="policy">
<arg-string>
<token-xpath expression="$current-node/@src-dn"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="current-group-name" scope="policy">
<arg-string>
<token-parse-dn length="1" start="-1"/>
<token-local-variable name="current-group-dn"/>
</arg-string>
</do-set-local-variable>
<do-if>
<arg-conditions>
<and>
<if-local-variable mode="regex" name="current-group-name"
op="equal"><same fancy regular expression></if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-trace-message>
<arg-string>
<token-text xml:space="preserve">Processing group: </token-text>
<token-local-variable name="current-group-dn"/>
</arg-string>
</do-trace-message>
</arg-actions>
<arg-actions/>
</do-if>
</arg-actions>
</do-for-each>
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 6706 reads


0