On 7/4/2012 10:16 PM, ayeungied wrote:
>
> Hi geoffc,
>
> 1) What is the trigger event?
> Two options: a) add a new value
> b) Remove a value
>
> YES.


You misunderstand. I want the trigger for the remove case, and the
trigger for the add case. What changes that fires this rule?

So my sample has no really meaningful conditions.

> 2) What is the result you want?
> proxyAddresses set to what? Looks like you are trying to build an LDIF
> file from this XSLT which is not how you would do it in IDM.
>
> My result is to set the proxyAddress as the following 4 items.
>
> proxyAddresses SMTP:ayeung1@abc.com.hk
> proxyAddresses x400:C=us;A= ;P=HKIEd;O=Exchange;S=User;G=ayeung1;
> proxyAddresses X400:C=US;A= ;P=HKIEd;O=Exchange;S=YEUNG1;G=Wing Hang,
> Agnes;
> proxyAddresses smtp:ayeung1@email.abc.com.hk
>
> Yes, we originally use the dirxml rules to geneate ldif file to process
> in AD. The source for generate the proxyAddress is
>
> <xsl:call-template name="update-sv-attribute">
> <xsl:with-param name="cn" select="$cn"/>
> <xsl:with-param name="mailou" select="$mailou"/>
> <xsl:with-param name="attr" select="'textEncodedORAddress'"/>
> <xsl:with-param name="value" select="concat('c=us;a=
> ;p=ABCd;o=Exchange;s=User;g=',$cn,';')"/>
> </xsl:call-template>
> <xsl:call-template name="update-sv-attribute">
> <xsl:with-param name="cn" select="$cn"/>
> <xsl:with-param name="mailou" select="$mailou"/>
> <xsl:with-param name="attr" select="'proxyAddresses'"/>
> <xsl:with-param name="value" select="concat('X400:c=us;a=
> ;p=ABCd;o=Exchange;s=User;g=',$cn,';')"/>
> </xsl:call-template>
> <xsl:if test="string-length($preferred-mail) > 0">
> <xsl:call-template name="add-attribute-value">
> <xsl:with-param name="cn" select="$cn"/>
> <xsl:with-param name="mailou" select="$mailou"/>
> <xsl:with-param name="attr" select="'proxyAddresses'"/>
> <xsl:with-param name="value"
> select="concat('SMTP:',$preferred-mail)"/>
> </xsl:call-template>
> </xsl:if>
>
>
> As I am a layman of programming, would you mind to point my nose to the
> right direction?


But this is a simple approach...

<rule>
<description>test</description>
<conditions>
<and>
<if-op-attr name="Internet EMail Address" op="changing"/>
</and>
</conditions>
<actions>
<do-add-dest-attr-value class-name="user" name="proxyAddresses">
<arg-value type="string">
<token-text xml:space="preserve">SMTP:</token-text>
<token-op-attr name="Internet EMail Address"/>
</arg-value>
</do-add-dest-attr-value>
<do-add-dest-attr-value class-name="user" name="proxyAddresses">
<arg-value type="string">
<token-text xml:space="preserve">smtp:</token-text>
<token-op-attr name="preferredAddress"/>
</arg-value>
</do-add-dest-attr-value>
<do-add-dest-attr-value class-name="user" name="proxyAddresses">
<arg-value type="string">
<token-text
xml:space="preserve">x400:c=us;a=;p=ABCd;o=Exchang e;s=User;g=</token-text>
<token-src-name/>
</arg-value>
</do-add-dest-attr-value>
<do-add-dest-attr-value class-name="user" name="proxyAddresses">
<arg-value type="string">
<token-text xml:space="preserve">X400:C=US;A=
;P=HKIEd;O=Exchange;S=</token-text>
<token-attr name="Surname"/>
<token-text xml:space="preserve">;G=</token-text>
<token-attr name="Given Name"/>
</arg-value>
</do-add-dest-attr-value>
</actions>
</rule>

Now I did not check for values in those attrs, but in the case of the
preferredAddress you could od it this way to make sure you have a value:

<do-for-each>
<arg-node-set>
<token-attr name="preferredAddress"/>
</arg-node-set>
<arg-actions>
<do-add-dest-attr-value class-name="user" name="proxyAddresses">
<arg-value type="string">
<token-text xml:space="preserve">smtp:</token-text>
<token-local-variable name="current-node"/>
</arg-value>
</do-add-dest-attr-value>
</arg-actions>
</do-for-each>

This way if there is a preferred address you loop once. if none, you
loop 0 times, if two you loop twice and add it twice.

Or else you could do:

<do-if>
<arg-conditions>
<and>
<if-attr mode="regex" name="preferredAddress" op="equal">.+</if-attr>
</and>
</arg-conditions>
<arg-actions>
<do-add-dest-attr-value class-name="user" name="proxyAddresses">
<arg-value type="string">
<token-text xml:space="preserve">smtp:</token-text>
<token-op-attr name="preferredAddress"/>
</arg-value>
</do-add-dest-attr-value>
</arg-actions>
<arg-actions/>
</do-if>

To test that it has a value (match means regex compare, .+ means 1 or
more values, so length of 1 or more).

And on and on...