Article
article
Reads:
2967
Score:
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>





0