Sample Scripts

The following sample scripts describes including additional functionalities in Create Rule Transform of Subscriber channel:


Uppercase and Lowercase for the User's CN Attribute

The following is a sample script for transforming the user's CN attribute value to having the first letter in uppercase and the rest in lowercase:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:variable name="ucase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
     <xsl:variable name="lcase" select="'abcdefghijklmnopqrstuvwxyz'"/>
     <xsl:template match="add[@class-name='User']/add-attr[@attr-name='CN']">
          <!--The following lines convert CN attribute value of User to first upper and rest lower case-->
          <xsl:variable name="orig-cn" select="./value"/>
          <xsl:variable name="first-string" select="substring($orig-cn,1,1)"/>
          <xsl:variable name="last-string" select="substring($orig-cn,2)"/>
          <xsl:variable name="new-cn" select="concat($first-string,translate($last-string,$ucase,$lcase))"/>
          <add-attr attr-name="CN">
               <value>
                    <xsl:value-of select="$new-cn"/>
               </value>
          </add-attr> 
     </xsl:template>
     <xsl:template match="@*|node()">
          <xsl:copy>
               <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
     </xsl:template>
</xsl:transform>

To implement specific business rules for groups, modify this script appropriately.


Lowercase for the User's CN Attribute

The following is a sample script for transforming the user's CN attribute value to all lowercase letters:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:variable name="ucase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
     <xsl:variable name="lcase" select="'abcdefghijklmnopqrstuvwxyz'"/>
     <xsl:template match="add[@class-name='User']/add-attr[@attr-name='CN']">
          <!-- The following two lines converts the CN attribute value of the User to lower case -->
          <xsl:variable name="orig-cn" select="./value"/>
     <xsl:variable name="new-cn" select="translate($orig-cn,$ucase,$lcase)"/>
      <add-attr attr-name="CN">
           <value>
                <xsl:value-of select="$new-cn"/>
           </value>
      </add-attr>
   </xsl:template>
   <xsl:template match="@*|node()">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
   </xsl:template>
</xsl:transform>

To implement specific business rules for groups, modify this script appropriately.