Novell Home

Selecting User/Group Data for Processing

Novell Cool Solutions: Tip

Digg This - Slashdot This

Posted: 13 Oct 2004
 

Selecting User and Group Data for Processing

by Bill Valaski

Note: Thanks to reader Bill Valaski for this timely tip, complete with an XML example for reference.

Problem

When performing modifications to a user object, I wanted to limit the information passed on to the connected JDBC database. This limit would be based on Group membership.

Solution

I created a query that retrieves a list of the Groups that the user is a member of, and then performs a test to see if they're a member of a particular Group. If the User matches the Group I'm looking for, the query copies the XML information to the output document for further processing.

XML Example

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="query cmd dncv" version="1.0"
xmlns:cmd="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsCommandProcessor"
xmlns:dncv="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.DNConverter"
xmlns:query="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsQueryProcessor" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <!-- parameters passed in from the DirXML engine -->

  <xsl:param name="srcQueryProcessor"/>
  <xsl:param name="destQueryProcessor"/>
  <xsl:param name="srcCommandProcessor"/>
  <xsl:param name="destCommandProcessor"/>
  <xsl:param name="dnConverter"/>
  <xsl:param name="fromNds"/>

  <!-- identity transformation template -->

  <!-- in the absence of any other templates this will cause -->
  <!-- the stylesheet to copy the input through unchanged to the output -->

  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <!-- add your custom templates here -->

  <xsl:template match="*[@class-name='User']">
    <!-- Create a query for Group=TSMembers -->
    <xsl:variable name="query-doc">
      <query dest-dn="{@src-dn}" scope="entry">
        <read-attr attr-name="Group Membership"/>       </query>
    </xsl:variable>

  v<!-- Execute the query -->

    <xsl:variable name="result" select="query:query($srcQueryProcessor,$query-doc)"/>

    <!-- Test if the group matches, if it does, copy the operation for further processing -->

    <xsl:if test="$result//value[./text()='\CDS_TREE\CDS\CDS_Cincy\TSMembers']">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell