<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.novell.com/communities" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Cool Solutions</title>
 <link>http://www.novell.com/communities/coolsolutions</link>
 <description>Place where the best and the brightest share their tips, tools and techniques with the rest of the Novell world.</description>
 <language>en</language>
<item>
 <title>Using Global Configuration Values in XPATH</title>
 <link>http://www.novell.com/communities/node/4825/using-global-configuration-values-xpath</link>
 <description> &lt;p&gt;Novell Identity Manager has several kinds of variables.  Local variables are what the name suggests, and have two levels of scoping, driver and &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/3000&quot;&gt;&lt;acronym title=&quot;In ZENworks Desktop Management, ZENworks Handheld Management, and ZENworks Server Management, a set of rules that define how workstations, handheld devices, and servers can be configured and controlled, including application availability and access, file access, and the appearance and contents of individual desktops. Policies are contained within policy packages, where they are also administered and customized.&quot;&gt;policy&lt;/acronym&gt;&lt;/a&gt;.  Driver scoping means the variable hangs around after definition for the duration of the event, throughout the policies in the driver.  This is a new feature in Identity Manager 3.5 and higher.  Policy scoping, the default if you do not say otherwise means that the variable remains only through the duration of this policy object.&lt;/p&gt;
&lt;p&gt;Global Configuration Variables (GCV from now on) are used to store things at the driver or the driver set level and can be very powerful.  This is very useful if you are developing in a lab tree, before promoting the solution to production and your tree layout is different in the lab.  You can store the references to base containers you use in a GCV and when it is time to move to production, just change those values to the correct ones for the production environment.  &lt;/p&gt;
&lt;p&gt;I detailed some examples of how to do that in a two part article about GCV&#039;izing the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2632&quot;&gt;&lt;acronym title=&quot;An advanced, hierarchical directory service that is an integral part of the Microsoft Windows 2000 architecture. It is LDAP-compliant and built on the Internet.&quot;&gt;Active Directory&lt;/acronym&gt;&lt;/a&gt; driver, see the following articles for some examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/4335/how-gcvize-a-driver-part-1-subscriber-channel&quot;&gt;How to GCVize a Driver, Part 1: Subscriber Channel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/4336/how-gcvize-a-driver-part-2&quot;&gt;How to GCVize a Driver, Part 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To reference these variables, there is a local variable token, and Global configuration variable token in Argument Builder, but a lot of fields do not use Argument Builder to specify.  For example, when testing the condition, Source DN, you could want to test if it is in the Subtree held in a variable.  &lt;/p&gt;
&lt;p&gt;In the example articles, I showed how to use the notation ~GCVName~ to represent a GCV in policy.  For local variables the notation is $VariableName.&lt;/p&gt;
&lt;p&gt;An additional place where the use of variables like this comes in handy, is within an XPATH expression.  &lt;/p&gt;
&lt;p&gt;For example, set a local variable CurrentDN to the current objects DN, say via the Source DN() token.  Lets say that the value is TREE-NAME\ACME\US\USERS\JSMITH&lt;/p&gt;
&lt;p&gt;Have a GCV called eDirActiveUsers that holds the value, ACME\US\USERS and you want to test if the Current DN is the subtree of the eDirActiveUsers container.  Lets say you also have a eDirDisabledUsers GCV that holds the value ACME\US\DISABLED&lt;/p&gt;
&lt;p&gt;Now if you were using a condition, and you selected Source DN or Destination DN condition tests, then Policy Builder would give you a couple of options.  You could test if it was in the subtree, in the container, equal, not equal and so on.  So not much advice I can offer here, as it is already built in.&lt;/p&gt;
&lt;p&gt;But what if CurrentDN is not the DN of the object in the current document?  Say you are using a Work Order driver, and a Work Order is created, and it references an object elsewhere in the tree.  Now you need to know before you proceed, is that user in the Active or Disabled container. &lt;/p&gt;
&lt;p&gt;Well Source DN and Destination DN condition tests in an IF token or the main tests for a rule only refer to the current object.  You could have some fun and store the value of Destination DN in another variable, lets call it CurrentDestDN and then do a Set Operation destination DN to the value of CurrentDN (the DN of the object the Work Order is referencing).  Now the destination DN of the current operation is the one you want to test.  Therefore you can use an IF token to test if Destination DN is in the subtree of ~eDirActiveUsers~ or ~eDirDisabledUsers~ as the case may be.  Do remember when you done to set operation destination DN back to the value you stored in the CurrentDestDN variable if that makes sense in what you are trying to accomplish.&lt;/p&gt;
&lt;p&gt;Now that previous example is a pretty stupid way to do it, but should work.  It turns out there is probably a much simpler approach using XPATH.&lt;/p&gt;
&lt;p&gt;The more I use and watch other people use XPATH the more I learn.  There are a couple of sites with some examples of XPATH (and to me something as complex, Regular Expressions) at: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://wiki.novell.com/index.php/XPATH_Examples&quot;&gt;http://wiki.novell.com/index.php/XPATH_Examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://wiki.novell.com/index.php/Regular_Expression_Examples&quot;&gt;http://wiki.novell.com/index.php/Regular_Expression_Examples&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;XPATH has a function called contains(), which takes two strings, and returns true if the second string is contained within the first string.&lt;/p&gt;
&lt;p&gt;For more XPATH functions, you can look at:&lt;br /&gt;
&lt;a href=&quot;http://www.w3.org/TR/1999/REC-xpath-19991116&quot;&gt;http://www.w3.org/TR/1999/REC-xpath-19991116&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is a nice reference, as I often find myself thinking, gee it would be nice to get the length of this string, but no DirXML Script tokens support it, check out the XPATH link above, and lookee here, there is an XPATH string-length(&quot;string&quot;) function. &lt;/p&gt;
&lt;p&gt;Back to our example, &lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;contains(&quot;I am Bob&quot;, &quot;Bob&quot;) 

&lt;/pre&gt;&lt;p&gt;
would return true.   How does this help?  Well XPATH in Identity Managers implementation also supports both classes of variables using $Local-Variable and ~GCVName~ notation.&lt;/p&gt;
&lt;p&gt;So therefore &lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;contains($CurrentDN, ~eDirActiveUsers~)

&lt;/pre&gt;&lt;p&gt;looks like it will work, right?  Well it would except that the way Identity Manager handles a local variable versus a GCV is slightly different.  Once you understand the difference it will be really easy to work with.&lt;/p&gt;
&lt;p&gt;Global configuration values, when used in tokens are treated just like variables, and looked up each time you run across them in a rule.  When I say look up, I mean retrieve from a list in memory, since a change to configuration of the driver, say changing a GCV but without restarting the driver will not cause it to take effect.&lt;/p&gt;
&lt;p&gt;When you use the ~GCVName~ notation, something different happens.  As the driver is started, it finds all instances of ~something~ and matches the &#039;something&#039; part, then replaces it with the literal string stored in the GCV.  Thus our line:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;contains($CurrentDN, ~eDirActiveUsers~)

&lt;/pre&gt;&lt;p&gt;
at run time will be interpreted as:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;contains(&quot;TREE-NAME\ACME\US\USERS\JSMITH&quot;, ACME\US\USERS)

&lt;/pre&gt;&lt;p&gt;
The $CurrentDN gets quotation marks because that is how variables are represented, but the GCV is a literal replacement of the string, so no quotes get added automatically.&lt;/p&gt;
&lt;p&gt;Thus to make it actually work, we would need to use:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;contains($CurrentDN, &quot;~eDirActiveUsers~&quot;)

&lt;/pre&gt;&lt;p&gt;
Then this would return true in our case, and you could react to that as appropriate.  &lt;/p&gt;
&lt;p&gt;Overall using a Global Configuration Value when you can for things that might change can be very powerful.  I am a huge fan of using them.&lt;/p&gt;
 &lt;div class=&quot;og_rss_groups&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;first last og_links&quot;&gt;&lt;a href=&quot;/communities/coolsolutions&quot; class=&quot;og_links&quot;&gt;Cool Solutions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description>
 <comments>http://www.novell.com/communities/node/4825/using-global-configuration-values-xpath#comments</comments>
 <category domain="http://www.novell.com/communities/taxonomy/term/6">DirXML</category>
 <category domain="http://www.novell.com/communities/coolsolutions/edirectory">eDirectory</category>
 <category domain="http://www.novell.com/communities/coolsolutions/nim">Identity Manager</category>
 <category domain="http://www.novell.com/communities/product/identitymanager/identitymanager35">Identity Manager 3.5</category>
 <category domain="http://www.novell.com/communities/taxonomy/term/32">Configuration</category>
 <category domain="http://www.novell.com/communities/topic/xpath">XPATH</category>
 <group domain="http://www.novell.com/communities/coolsolutions/ism" xmlns="http://drupal.org/project/og">Identity &amp;amp; Security Management Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions" xmlns="http://drupal.org/project/og">Cool Solutions</group>
 <pubDate>Sun, 08 Nov 2009 09:41:35 -0700</pubDate>
 <dc:creator>geoffc</dc:creator>
 <guid isPermaLink="false">4825 at http://www.novell.com/communities</guid>
</item>
<item>
 <title>Cool tricks using XPATH on nodesets</title>
 <link>http://www.novell.com/communities/node/5686/cool-tricks-using-xpath-nodesets</link>
 <description> &lt;p&gt;Novell Identity Manager is a very powerful system that has many components.  There is the core engine, that watches for events in &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/3276&quot;&gt;&lt;acronym title=&quot;A distributed, replicated naming service that maintains information about and provides access to a list of objects that represent network resources, such as network users, servers, printers, print queues, and applications. The directory is physically stored as a set of database files on a server. If the server hosts file system volumes, these files are on volume sys:. If no volumes are present, the directory is stored on the server&#039;s local disk. eDirectory tightly integrates Novell Security Services for e-commerce (PKI, cryptography, and authentication services), allowing developers to build applications that can be accessed and managed across the entire network through explicit policies.&quot;&gt;eDirectory&lt;/acronym&gt;&lt;/a&gt; (dxevent) and sends them out to the drivers according to what the filters for each driver are listening for, processing the rules along the way (vrdim).  There are driver shims for many different connected systems.  There are well over a dozen different drivers for well known systems, some like the JDBC, &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1613&quot;&gt;&lt;acronym title=&quot;Lightweight Directory Access ProtocolAn X.500-related Open Systems Interconnection (OSI) protocol that clients can use to read and write Directory information. LDAP is used to publish Directory information such as telephone numbers and e-mail addresses. The Directory features available to LDAP clients are dependent upon the features built into the LDAP server and the LDAP client; some clients have the ability to read and write data; others can only read Directory data.Web browsers and e-mail programs can query an LDAP-compliant directory (for example, Novell eDirectory).LDAP allows a client to search through a large database of addresses, phone numbers, and people stored on a server.&quot;&gt;LDAP&lt;/acronym&gt;&lt;/a&gt;, Delimited Text, and SOAP drivers are sufficiently generic to support dozens of different systems each.  (For example the JDBC driver can talk to Oracle, MS SQL, Postgress, MySQL, or DB2 databases and that counts as a single driver).  These drivers watch for events in their connected systems and send them to the engine for processing.  Then there is the User Application which is a whole other world, almost a completely different product.&lt;/p&gt;
&lt;p&gt;At the heart of all this is the engine, and in addition to seeing events in eDirectory it processes the rules, style sheets, and other objects that are part of the drivers.&lt;/p&gt;
&lt;p&gt;There are many tools at your disposal for use by the engine.  You can write your rules using XSLT style sheets, the original approach.  This is probably the most complex approach, unless XSLT is something you are very comfortable with.  NSure Identity Manager 2.0 introduced DirXML Script, which is an XML based language with nouns, verbs, tokens, actions, condition tests, and what not that allow you to process events in a much more user friendly manner.  The tool used to build rules in DirXML Script, Policy Builder is very powerful, and is exposed in &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2869&quot;&gt;&lt;acronym title=&quot;Novell iManagerA browser-based management utility included with NetWare 6. In ZENworks Server Management, it enables administrators to manage Tiered Electronic Distribution (TED) objects, agents, and processes from any location where the required version of Internet Explorer is available.&quot;&gt;iManager&lt;/acronym&gt;&lt;/a&gt;&#039;s plugins for Identity Manager, and Designer for Identity Manager. &lt;/p&gt;
&lt;p&gt;Within both XSLT style sheets and DirXML Script it is possible to use XPATH, the XML Path language to do a whole host of other things.  XPATH includes a number of string processing functions like contains(), subtring-before(), and many more functions, see &lt;a href=&quot;http://www.w3.org/TR/1999/REC-xpath-19991116&quot; title=&quot;http://www.w3.org/TR/1999/REC-xpath-19991116&quot;&gt;http://www.w3.org/TR/1999/REC-xpath-19991116&lt;/a&gt; for the full definition.  Note that only version 1.0 of XPATH is supported, not 2.0.  Last I heard XPATH 2.0 was not fully backwards compatible and can break XPATH 1.0 rules.  Thus upgrading could be very complex and the developers for Novell Identity Manager are still working out how to handle this issue.&lt;/p&gt;
&lt;p&gt;One of the very cool things you can do with XPATH that greatly extends the power of Novell Identity Manager is the ability to call a &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1591&quot;&gt;&lt;acronym title=&quot;An object-oriented programming language developed by Sun Microsystems, Inc. to create executable content (ie, self-running applications) that can be easily distributed through networks like the Internet. Developers use Java to create special programs called applets that can be incorporated in web pages to make them interactive. A Java-enabled web browser is required to interpret and run the Java applets.&quot;&gt;Java&lt;/acronym&gt;&lt;/a&gt; function (I suppose any Java function you happen to have installed on the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2314&quot;&gt;&lt;acronym title=&quot;A powerful computer running software that supplies network clients with services, such as file, print, communication, or application services. Examples of servers include1. Routing servers, which connect nodes and networks of similar architectures2. Gateway servers, which connect nodes and networks of different architectures by performing protocol conversions3. Terminal servers, print servers, disk servers, and file servers, which provide an interface between compatible peripheral devices on a local area network&quot;&gt;server&lt;/acronym&gt;&lt;/a&gt;).  With Identity Manager 3.5 and higher they added the ability to call ECMAScript functions as well from XPATH.  This way if you cannot do it in DirXML Script, you can write your own function in either Java and call it, or in ECMAScript and call it via XPATH.  &lt;/p&gt;
&lt;p&gt;In this article, &lt;a href=&quot;http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager&quot;&gt;http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager&lt;/a&gt; I discussed a couple of general uses for XPATH, and the basic approaches you can take to using it.  &lt;/p&gt;
&lt;p&gt;Another function that came up recently for me, that turns out to be extremely powerful is using the DirXML Script action, do-strip-xpath action.  Now I always thought of using this action to remove a value from the current XDS document.   For example, you want to remove a &amp;lt;remove-all-values&amp;gt; node from the current operation, you could do-strip-xpath with an XPATH expression of something like &amp;lt;do-strip-xpath expression=&#039;modify-attr[@attr-name=&quot;SomeAttribute&quot;]/remove-all-values&#039;/&amp;gt; and this is a pretty useful thing to be able to do.  Especially in the case where you know a remove all values is going to come from the connected system on a particular event, but your REALLY do not want it to do that.  This way you can remove it from the XDS event document before it gets sent to eDirectory (or vica versa, depending on the channel you are currently in).&lt;/p&gt;
&lt;p&gt;What I recently was pointed at, is the fact that you can use the do-strip-xpath action against any nodeset, not just the current operational document.  After all, both are just DOM objects in memory.   &lt;/p&gt;
&lt;p&gt;The most common nodeset I deal with is the result of a Query token.  For more on the Query token you could read the article:&lt;br /&gt;
&lt;a href=&quot;http://www.novell.com/communities/node/4906/the-query-token-identity-manager&quot; title=&quot;http://www.novell.com/communities/node/4906/the-query-token-identity-manager&quot;&gt;http://www.novell.com/communities/node/4906/the-qu...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A particular example I ran into was querying the file and print &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2817&quot;&gt;&lt;acronym title=&quot;A Directory tree that consists of eDirectory objects such as multiple levels of organizational units, users, groups, and other network resources.&quot;&gt;eDirectory tree&lt;/acronym&gt;&lt;/a&gt; for &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/3314&quot;&gt;&lt;acronym title=&quot;Access Control ListExtension of the conventional permission concept for files and directories.&quot;&gt;ACL&lt;/acronym&gt;&lt;/a&gt; values.  I was trying to find users with excessive amounts of rights.  Turns out there were all sorts of optimization tricks I used, but this one is still my favorite.  I queried back for all Organizational Units with ACL attributes on them, and that generated a relatively large  document that I stored in a local variable as a nodeset.  Now a nodeset in this context is really a DOM object stored in memory.  &lt;/p&gt;
&lt;p&gt;The thing is, I knew there were a stack of ACL&#039;s returned by my query that I could care less about, and really did not want to waste time processing.&lt;/p&gt;
&lt;p&gt;Things like rights granted to WM:Workstation Registration.  Turns out this tree had Zenworks 2.0 installed in it years ago, and in Zenworks 2.0 to register a workstation, the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1156&quot;&gt;&lt;acronym title=&quot;An eDirectory object that can hold, or contain, other objects. Container objects are used to logically group related objects in the eDirectory tree to provide those objects with rights and services. Common examples of container objects are Country, Organization, and Organizational Unit.&quot;&gt;container object&lt;/acronym&gt;&lt;/a&gt; get granted W to itself on the attribute WM:Workstation Registration.  This allowed the Zen workstation registration tool (wsreg32.exe was it?) to write a string with all the info about the workstation on the container.  Then in NWAdmin (who remembers that anymore?) you could use a plugin to create Workstation objects from the registration info.  Overall, this was an approach to the problem.  Probably not a GOOD approach, in hindsight, but hey that was almost ten years ago now, so I will cut them some slack.  (The problem was that you could easily get hundreds to thousands of registration values on a container object that had to be synchronized and really had no long term value.  Also, even after you were done using it, old clients would continue populating the values onto the container object.  At the same time, NDS (this was before they renamed it to eDirectory) had some issues with hugely multi valued attributes.  Now a days it would not be a big deal.  (Worth noting that Dsrepair still reports objects with over 1000 object references, even though it does not really matter that much today).&lt;/p&gt;
&lt;p&gt;Anyway, every container in the tree had WM:Workstation Registration set, and normally that would be the type of ACL I would want to notice, except that it really does not matter to me.  I considered looping through the nodeset in a for-each loop, and testing that it was not WM:Workstation Registration, but that turned out to take a reasonable amount of time.  I.e. Looping through a few thousands nodes can take more time than you might like.&lt;/p&gt;
&lt;p&gt;Then I had all the other default ACL&#039;s that I did care about like R to Login Script on every container.  Again, that is one more test inside that loop through all the ACL values.  More time.&lt;/p&gt;
&lt;p&gt;Father Ramon from the Novell Support Forums (You do read and search the Forums when you need help, right?  Of course you do!  There is a web interface at &lt;a href=&quot;http://forums.novell.com&quot; title=&quot;http://forums.novell.com&quot;&gt;http://forums.novell.com&lt;/a&gt; where you can login with your Novell ID that you use for opening incidents and downloading patches, and there is an &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1888&quot;&gt;&lt;acronym title=&quot;Network News Transfer ProtocolThe basic Internet protocol used to exchange network news articles between multiple news servers and between news servers and newsreaders.&quot;&gt;NNTP&lt;/acronym&gt;&lt;/a&gt; interface at the same IP name. nntp://forums.novell.com and look for the novell.support.identity-manager.engine-drivers forum.  Lots of excellent content there), suggested that I use do-strip-xpath against the local variable nodeset.&lt;/p&gt;
&lt;p&gt;Thus for the local variable ACLS the line below accomplishes what I needed all by its lonesome.&lt;br /&gt;
&amp;lt;do-strip-xpath expression=&quot;$ACLS//value[(component[@name = &#039;protectedName&#039;] = &#039;WM:Registered Workstation&#039;)]&quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt;This is even more powerful when you realize that ACL is structured attribute with three components.  If you want to set such a value, you need to provide all three components, like in this action:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;do-add-dest-attr-value class-name=&quot;User&quot; name=&quot;ACL&quot;&amp;gt;
	&amp;lt;arg-value type=&quot;structured&quot;&amp;gt;
		&amp;lt;arg-component name=&quot;protectedName&quot;&amp;gt;
			&amp;lt;token-text xml:space=&quot;preserve&quot;&amp;gt;CN&amp;lt;/token-text&amp;gt;
		&amp;lt;/arg-component&amp;gt;
		&amp;lt;arg-component name=&quot;trustee&quot;&amp;gt;
			&amp;lt;token-text xml:space=&quot;preserve&quot;&amp;gt;\ACME\lab\users&amp;lt;/token-text&amp;gt;
		&amp;lt;/arg-component&amp;gt;
		&amp;lt;arg-component name=&quot;privileges&quot;&amp;gt;
			&amp;lt;token-text xml:space=&quot;preserve&quot;&amp;gt;33&amp;lt;/token-text&amp;gt;
		&amp;lt;/arg-component&amp;gt;
	&amp;lt;/arg-value&amp;gt;
&amp;lt;/do-add-dest-attr-value&amp;gt;

&lt;/pre&gt;&lt;p&gt;
The ACL is written to an object that the right is granted upon.  I.e. If the ACL is on the Tree Root, then the right specified by the value of the ACL is being granted at the Tree Root level.  (This could be very bad, if you are not careful!  This right will potentially inherit all the way down the tree!  So please think twice, then a third time if doing something like this at the Tree Root level.)&lt;/p&gt;
&lt;p&gt;Then the component &#039;protectedName&#039; is the attribute that the trustee is being granted for.  This would be the Attribute name in the eDirectory schema.  The example above is for CN, but any attribute is possible.  There are some special ones like [All Attributes], [Entry Rights], \[Inheritance Mask] (for Inherited Rights Filters), and possibly others.&lt;/p&gt;
&lt;p&gt;The component &#039;trustee&#039; is the user who is being granted the ACL to the object the ACL is written on.  So in our case, it looks like a container named users.lab in the ACME tree is getting the right to the CN attribute, on wherever our destination object happens to be.  (The example is a simple snippet, so that detail is not specified, but it could be!) &lt;/p&gt;
&lt;p&gt;Finally the &#039;privileges&#039; component is a bit mask of the values you set in the NDS Rights tab in Console 1, or via iManager, (or via NWAdmin32 even!  Any tool than can manipulate eDirectory ACL&#039;s can do this.  Technically that is what our set destination attribute example above is doing as well).  The mapping of the values depends if it is an Entry or Attribute right, but for simplicity in the Attribute case, 33 is 32 for Supervisor rights plus 1 for Compare rights. &lt;/p&gt;
&lt;p&gt;Alas, you cannot query for components of a structured attributes, which also would have solved my problem.  &lt;/p&gt;
&lt;p&gt;So instead, what we do is strip by XPATH the expression:&lt;br /&gt;
$ACLS//value[(component[@name = &#039;protectedName&#039;] = &#039;WM:Registered Workstation&#039;)]&lt;/p&gt;
&lt;p&gt;$ACLS means in the context of the variable $ACLS (which is conveniently a nodeset), //value means find any occurrence of a value node, with the predicate of component[@name = &#039;protectedName&#039;] = &#039;WM:Registered Workstation&#039;).  Within that predicate, look for the component named &#039;protectedName&#039;, whose value is WM:Registered Workstation.  &lt;/p&gt;
&lt;p&gt;So this removes all value nodes where the trustee of the ACL is WM:Registered Workstation.  Cool.  &lt;/p&gt;
&lt;p&gt;Your variable goes in with hundreds or thousands of values, and in one line of DirXML Script, hundreds of values I want removed, are removed!  Yay!&lt;/p&gt;
&lt;p&gt;Then do it again for Login Script:&lt;br /&gt;
&amp;lt;do-strip-xpath expression=&quot;$ACLS//value[(component[@name = &#039;protectedName&#039;] = &#039;Login Script&#039;)]&quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt;Then do it again for SAS:Login Configuration and SAS:Login Configuration Key, and now your thousands of nodes in your nodeset is a much smaller set that when you loop through it, takes hugely less time!&lt;/p&gt;
&lt;p&gt;Looking at the trace on a SUSE Linux box, running eDir 8.8.1 FT2, on modern server hardware, it took about 15 milliseconds to remove all the ACL&#039;s with a privileges value below 4 (which would remove values of 1, 2, or 3 which would be Read and Compare or just Read or just compare, it is a bit mask) and there were TONS of those.  The rest of do-strips took between 1-5 milliseconds.  &lt;/p&gt;
&lt;p&gt;You just cannot run through a for-each loop that fast.  &lt;/p&gt;
&lt;p&gt;So for my example I did 6 do-strip-xpath operations, and it took about 19 milliseconds total.  &lt;/p&gt;
&lt;p&gt;My initial brute force approach took over 40 minutes looping through all the values and testing and doing much more work.  This approach cut the total time down to under 2 minutes.  That is pretty darn fine!  (10,000 object tree with all sorts of weird historical ACL values set all over the place).&lt;/p&gt;
&lt;p&gt;I never would have thought that a local variable nodeset can be treated in a similar way to the current document nodeset and tweaked this way, but boy did it work well!&lt;/p&gt;
&lt;p&gt;Now that I have this hammer of do-strip-xpath, everything is starting to look like a nodeset nail...  Every time I have a nodeset variable I keep trying to think of a way to use this on it somehow.&lt;/p&gt;
 &lt;div class=&quot;og_rss_groups&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;first last og_links&quot;&gt;&lt;a href=&quot;/communities/coolsolutions&quot; class=&quot;og_links&quot;&gt;Cool Solutions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description>
 <comments>http://www.novell.com/communities/node/5686/cool-tricks-using-xpath-nodesets#comments</comments>
 <category domain="http://www.novell.com/communities/taxonomy/term/6">DirXML</category>
 <category domain="http://www.novell.com/communities/coolsolutions/edirectory">eDirectory</category>
 <category domain="http://www.novell.com/communities/coolsolutions/nim">Identity Manager</category>
 <category domain="http://www.novell.com/communities/product/identitymanager/identitymanager35">Identity Manager 3.5</category>
 <category domain="http://www.novell.com/communities/topic/xpath">XPATH</category>
 <group domain="http://www.novell.com/communities/coolsolutions/ism" xmlns="http://drupal.org/project/og">Identity &amp;amp; Security Management Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions" xmlns="http://drupal.org/project/og">Cool Solutions</group>
 <pubDate>Sun, 08 Nov 2009 09:41:17 -0700</pubDate>
 <dc:creator>geoffc</dc:creator>
 <guid isPermaLink="false">5686 at http://www.novell.com/communities</guid>
</item>
<item>
 <title>Using XPATH to examine Association values</title>
 <link>http://www.novell.com/communities/node/5845/using-xpath-examine-association-values</link>
 <description> &lt;p&gt;Novell Identity Manager has an advantage over some of its competitors based on how it stores the association values for synchronized objects.  Other products may use a directory to combine all the data about the users, but often they do not store the information about associations, that is connections between objects in the different systems, within that directory.  &lt;/p&gt;
&lt;p&gt;The way Novell Identity Manager does it is quite advantageous, since you can examine the directory on any object and see what the association values are, without needing to look into another location to retrieve the information.&lt;/p&gt;
&lt;p&gt;The values are stored in &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/3276&quot;&gt;&lt;acronym title=&quot;A distributed, replicated naming service that maintains information about and provides access to a list of objects that represent network resources, such as network users, servers, printers, print queues, and applications. The directory is physically stored as a set of database files on a server. If the server hosts file system volumes, these files are on volume sys:. If no volumes are present, the directory is stored on the server&#039;s local disk. eDirectory tightly integrates Novell Security Services for e-commerce (PKI, cryptography, and authentication services), allowing developers to build applications that can be accessed and managed across the entire network through explicit policies.&quot;&gt;eDirectory&lt;/acronym&gt;&lt;/a&gt; in an attribute called DirXML-Associations.  The DirXML-Associations attribute uses an interesting syntax, called Path syntax.  Path is a compound or structured attribute syntax that has three parts to it.  An integer (I think it has a max range, but we only ever use 0-5 so not sure) named nameSpace, then a &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/552&quot;&gt;&lt;acronym title=&quot;A Lightweight Directory Access Protocol (LDAP) distinguished name (DN) is an LDAP entry that identifies and describes an authorized user for an LDAP server.Distinguished names consist of the name of the entry itself as well as the names, in order from bottom to top, of the objects above it in the directory. LDAP supports only one format for a distinguished name: typeful with commas as the delimiter. For example:CN=JRoss, OU=HR, O=Acme&quot;&gt;distinguished name&lt;/acronym&gt;&lt;/a&gt; syntax field called &quot;volume&quot;, and finally a string field called &quot;path&quot;.  This was designed to store things like a &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1463&quot;&gt;&lt;acronym title=&quot;1. In the Common Desktop Environment (CDE), a directory where you keep personal files and additional directories. By default, the File Manager and Terminal Emulator windows are set to the home directory when you first open them.2. A network directory that the network administrator can create for a user. The user should keep personal files in this directory (usually in /home/). Except for the superuser root, only the owner has full access rights in the home directory.&quot;&gt;home directory&lt;/acronym&gt;&lt;/a&gt; path, where you need to specify the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/3247&quot;&gt;&lt;acronym title=&quot;Controls the syntax of naming, such as which characters are legal in filenames and path separators, how long the name can be, and whether case is significant and/or preserved. Every volume must have one or more name spaces associated with it. If a volume has more than one name space associated with it, valid filenames will be maintained on that volume for all of its name spaces. If a file name is legal in more than one name space, it is stored only once and shared by the name spaces.&quot;&gt;name space&lt;/acronym&gt;&lt;/a&gt; the path is in, (DOS, &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1879&quot;&gt;&lt;acronym title=&quot;Network File SystemA distributed file system developed by Sun Microsystems that allows a set of computers to access each other&#039;s files cooperatively in a transparent manner.&quot;&gt;NFS&lt;/acronym&gt;&lt;/a&gt;, LONG, OS2, MAC, etc...  Shades of the old NetWare days eh?), then the distinguished name of the volume object, and finally a free form &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/679&quot;&gt;&lt;acronym title=&quot;A rectangular area in a window where information is typed. Text fields with keyboard focus have a blinking text insertion cursor.&quot;&gt;text field&lt;/acronym&gt;&lt;/a&gt; for the path on the volume.  &lt;/p&gt;
&lt;p&gt;The DN reference to the volume is the reason why if you deleted a &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2314&quot;&gt;&lt;acronym title=&quot;A powerful computer running software that supplies network clients with services, such as file, print, communication, or application services. Examples of servers include1. Routing servers, which connect nodes and networks of similar architectures2. Gateway servers, which connect nodes and networks of different architectures by performing protocol conversions3. Terminal servers, print servers, disk servers, and file servers, which provide an interface between compatible peripheral devices on a local area network&quot;&gt;server&lt;/acronym&gt;&lt;/a&gt; or volume object in eDirectory, all the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1464&quot;&gt;&lt;acronym title=&quot;Short for &quot;Home Directory property.&quot;&quot;&gt;Home Directory&lt;/acronym&gt;&lt;/a&gt; mappings would go away.  DN syntax fields do not store the string of the DN of the object, rather it stores a 32 bit integer that describes the entry in the eDirectory &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/540&quot;&gt;&lt;acronym title=&quot;A collection of information organized and presented to serve a specific purpose. (A telephone book is a common database.) A computerized database is an updated, organized file of machine readable information that is rapidly searched and retrieved by computer.The term database is often erroneously referred to as a synonym for a database management system (DBMS). They are not equivalent. A database is a store of data that describe entities and the relationships between the entities. A database management system is the software mechanism for managing that data.&quot;&gt;database&lt;/acronym&gt;&lt;/a&gt;.  Thus every tool that displays the DN to a human, basically does a look up for the current display name of the object.  Thus renames, and moves, are automatically displayed correctly at all times.  However, if you delete the object and then recreate it, even when the names are the same, the object IDs are different (eDirectory may eventually reuse an object ID, but there is no way to force it or request it, so you can basically be guaranteed a different object ID).&lt;/p&gt;
&lt;p&gt;That does bring up an important point with DirXML-Associations values, and if you are updating the drivers.  You might be tempted, when the time comes to do an upgrade to the system, to just delete all the DirXML Driver objects and re-import them from your lab model, but this illuminates a big pitfall.  All the DirXML-Association values are based on the DN (the Volume part of the structured attribute) of the current DirXML Driver object.  If that gets deleted, all the DirXML-Association values just magically go away.  &lt;/p&gt;
&lt;p&gt;If you have to take that approach, then delete everything UNDER the Driver object, but leave the Driver object behind so that the DirXML-Associations remain.  &lt;/p&gt;
&lt;p&gt;There are several good tools to back up the values.  From the commercial world Blackbird Detroubler (&lt;a href=&quot;http://www.blackbird-group.com/&quot; title=&quot;http://www.blackbird-group.com/&quot;&gt;http://www.blackbird-group.com/&lt;/a&gt;)is one of the best tools for backing up eDirectory in general, since it is smart enough to recognize cross links between objects.  That is, if you deleted your DirXML Driver object accidentally (or on purpose) and regret it, it can restore the objects, but also it can restore the association values on all the objects that had them.  It is quite impressive, and to the best of my knowledge a unique feature in the market.  Other products will restore the objects (possibly with the same object ID, but not likely) and then it is up to you to restore the references on the other objects.  &lt;/p&gt;
&lt;p&gt;From the free world, Novell Professional services out of Hungary released the super cool tool, DAModifier.  You can get it from: &lt;a href=&quot;http://www.npsh.hu/associmod_en.html&quot; title=&quot;http://www.npsh.hu/associmod_en.html&quot;&gt;http://www.npsh.hu/associmod_en.html&lt;/a&gt; or &lt;a href=&quot;http://www.novell.com/communities/node/958/association+modifier&quot;&gt;http://www.novell.com/communities/node/958/association+modifier&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;This free tool is a Windows tool, that requires an NCP over Client 32 connection.  You can pick the tree, the driver object, the context to search in, and the kind of association value you wanted.  You can use it to show the current values, and save it to a file, and at a later date restore them from a file.  This gets around the DN syntax issue, by storing and referencing the names of the DirXML Driver object, so that when it goes to restore the value, it has to lookup the actual current Object ID that belongs to the name.  &lt;/p&gt;
&lt;p&gt;For a listing of the various known association values (The &quot;Path&quot; part of the structured attribute) check out this article on the topic:&lt;br /&gt;
&lt;a href=&quot;http://www.novell.com/communities/node/1696/open-call-idm-association-values-edirectory-objects&quot;&gt;Open Call - IDM Association Values for eDirectory Objects&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Within a driver, there are a couple of DirXML Script tokens, conditions, and actions that can look at Association values.&lt;/p&gt;
&lt;p&gt;In the Condition block of rules, you can select an If association, and the tests are things like, Associated, not associated, available, and then the usual set of equal, not equal, less than, not less than, and friends.  &lt;/p&gt;
&lt;p&gt;The less than, greater than tests do not seem all that useful, until you consider that the value of the association, the &quot;Path&quot; part of the structured attribute is just a text string.  So perhaps in the case of a driver to a Unix style system, it might be storing uid numbers, in which case testing if the number is below 1024 could be useful and tell you something about the user.  (Now it happens that the bi-directional Linux Unix driver happens to use the users CN followed by the string User or Group, so a User named jsmith would have an association value of jsmithUser and group named Shovellers would have an association value of ShovellersGroup but it was a nice example even if it makes no sense in reality).   Some databases might use the value of a primary key sequence number (say a column called pk_sequence) that is incremented, and you want to know if a users row in the database is below or above some value. &lt;/p&gt;
&lt;p&gt;In the Action block of a rule, you can Add Association or Remove Association.  Remove Association is a great action, if you want to dis-associate users after an event, say if one system deletes the user, we often convert the delete event into a Remove Association and disable user (Set Login Disabled equal true).  Lets say in the case of a JDBC driver, where you are synchronizing a view, instead of a real table, and there is some criteria that defines your view, and users can change to be in or out of the view.  Say some value is Active or Inactive and that defines your view.  When they go inactive, it would come across as a delete, since it has disappeared from the view.  In a case such as that, you would want to remove the association so that if the user becomes Active again, and appears in the view, you would want to match on the user again, but if the user still has an association value it will not match correctly. &lt;/p&gt;
&lt;p&gt;In the Argument Builder, basically anywhere you can build a string, you can use the Association token to use the current association value.  Source Attribute and Destination Attribute can reference a specific object other than the one in the current operation if you give a DN or Association value to look for.  &lt;/p&gt;
&lt;p&gt;The problem of all these approaches however if that they are focused on the Association of the current object, and for the current driver.  There are many powerful use cases where in a different driver (often a Null or Loopback driver) it would be useful to know if the user is associated to a particular system.&lt;/p&gt;
&lt;p&gt;The good news is that with XPATH you can accomplish much of what you need.  I am trying to do a series of articles on the use of XPATH in Identity Manager, since the context for an Identity Manager event (which is key when selecting in XPATH), is different than you would see in documentation for XPATH elsewhere on the web.  You can see the previous articles at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager&quot;&gt;Some thoughts on XPATH in Novell Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/4825/using-global-configuration-values-xpath&quot;&gt;Using Global Configuration Values in XPATH&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/5686/cool-tricks-using-xpath-nodesets&quot;&gt;Cool tricks using XPATH on nodesets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/5818/different-attribute-options-identity-manager&quot;&gt;The different attribute options in Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can query for the DirXML-Associations on an object with the Query token quite readily.  &lt;/p&gt;
&lt;p&gt;For example this action will set a local variable ASSOC-VAL with a node set filled with the data from the Query for a user with a workforceID of the local variable WORKFORCE-ID.&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;do-set-local-variable name=&quot;ASSOC-QUERY&quot; scope=&quot;policy&quot;&amp;gt;
	&amp;lt;arg-node-set&amp;gt;
		&amp;lt;token-query class-name=&quot;User&quot; datastore=&quot;src&quot;&amp;gt;
			&amp;lt;arg-match-attr name=&quot;workforceID&quot;&amp;gt;
				&amp;lt;arg-value type=&quot;string&quot;&amp;gt;
					&amp;lt;token-local-variable name=&quot;WORKFORCE-ID&quot;/&amp;gt;
				&amp;lt;/arg-value&amp;gt;
			&amp;lt;/arg-match-attr&amp;gt;
			&amp;lt;arg-string&amp;gt;
				&amp;lt;token-text xml:space=&quot;preserve&quot;&amp;gt;DirXML-Associations&amp;lt;/token-text&amp;gt;
			&amp;lt;/arg-string&amp;gt;
		&amp;lt;/token-query&amp;gt;
	&amp;lt;/arg-node-set&amp;gt;
&amp;lt;/do-set-local-variable&amp;gt;

&lt;/pre&gt;&lt;p&gt;
This will return a document something like the following into the node set.&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;nds dtdversion=&quot;3.5&quot; ndsversion=&quot;8.x&quot;&amp;gt;
  &amp;lt;source&amp;gt;
    &amp;lt;product version=&quot;3.5.11.20080307 &quot;&amp;gt;DirXML&amp;lt;/product&amp;gt;
    &amp;lt;contact&amp;gt;Novell, Inc.&amp;lt;/contact&amp;gt;
  &amp;lt;/source&amp;gt;
  &amp;lt;output&amp;gt;
    &amp;lt;instance class-name=&quot;User&quot; qualified-src-dn=&quot;O=LAB\OU=EMPLOYEES\OU=NEW\CN=JSmith&quot; src-dn=&quot;\ACME-LAB\LAB\EMPLOYEES\NEW\LJohnson1&quot; src-entry-id=&quot;56795&quot;&amp;gt;
      &amp;lt;attr attr-name=&quot;DirXML-Associations&quot;&amp;gt;
        &amp;lt;value timestamp=&quot;1217007039#71&quot; type=&quot;structured&quot;&amp;gt;
          &amp;lt;component name=&quot;nameSpace&quot;&amp;gt;1&amp;lt;/component&amp;gt;
          &amp;lt;component name=&quot;volume&quot;&amp;gt;\ACME-LAB\LAB\SERVICES\IDVAULT\APP-JDBC&amp;lt;/component&amp;gt;
          &amp;lt;component name=&quot;path&quot;&amp;gt;PK_SEQUENCE=350110,table=CLIENTS,schema=IDM&amp;lt;/component&amp;gt;
        &amp;lt;/value&amp;gt;
        &amp;lt;value timestamp=&quot;1217007039#72&quot; type=&quot;structured&quot;&amp;gt;
          &amp;lt;component name=&quot;nameSpace&quot;&amp;gt;1&amp;lt;/component&amp;gt;
          &amp;lt;component name=&quot;volume&quot;&amp;gt;\ACME-LAB\LAB\SERVICES\IDVAULT\LinuxUnixSettings&amp;lt;/component&amp;gt;
          &amp;lt;component name=&quot;path&quot;&amp;gt;YE98+yxf3AGAleAAAwAAAA==&amp;lt;/component&amp;gt;
        &amp;lt;/value&amp;gt;
        &amp;lt;value timestamp=&quot;1217007039#73&quot; type=&quot;structured&quot;&amp;gt;
          &amp;lt;component name=&quot;nameSpace&quot;&amp;gt;1&amp;lt;/component&amp;gt;
          &amp;lt;component name=&quot;volume&quot;&amp;gt;\ACME-LAB\LAB\SERVICES\IDVAULT\UserApplication35&amp;lt;/component&amp;gt;
          &amp;lt;component name=&quot;path&quot;&amp;gt;&quot;AnAssociation&quot;&amp;lt;/component&amp;gt;
        &amp;lt;/value&amp;gt;
        &amp;lt;value timestamp=&quot;1217007039#74&quot; type=&quot;structured&quot;&amp;gt;
          &amp;lt;component name=&quot;nameSpace&quot;&amp;gt;1&amp;lt;/component&amp;gt;
          &amp;lt;component name=&quot;volume&quot;&amp;gt;\ACME-LAB\LAB\SERVICES\IDVAULT\Active Directory&amp;lt;/component&amp;gt;
          &amp;lt;component name=&quot;path&quot;&amp;gt;f0648eab27d6da4283246583112d6319&amp;lt;/component&amp;gt;
        &amp;lt;/value&amp;gt;
        &amp;lt;value timestamp=&quot;1217007039#75&quot; type=&quot;structured&quot;&amp;gt;
          &amp;lt;component name=&quot;nameSpace&quot;&amp;gt;1&amp;lt;/component&amp;gt;
          &amp;lt;component name=&quot;volume&quot;&amp;gt;\ACME-LAB\LAB\SERVICES\IDVAULT\Corporate Password Sync&amp;lt;/component&amp;gt;
          &amp;lt;component name=&quot;path&quot;&amp;gt;E101738&amp;lt;/component&amp;gt;
        &amp;lt;/value&amp;gt;
      &amp;lt;/attr&amp;gt;
      &amp;lt;/instance&amp;gt;
      &amp;lt;/output&amp;gt;
      &amp;lt;/nds&amp;gt;
	  
	  &lt;/pre&gt;&lt;p&gt;
You could also use the Source attribute token if you are interested in the current user object, or can specify its DN or Association value.   That might look like:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;do-set-local-variable name=&quot;ASSOC-VALS&quot; scope=&quot;policy&quot;&amp;gt;
	&amp;lt;arg-node-set&amp;gt;
		&amp;lt;token-src-attr name=&quot;DirXML-Associations&quot;/&amp;gt;
	&amp;lt;/arg-node-set&amp;gt;
&amp;lt;/do-set-local-variable&amp;gt;

&lt;/pre&gt;&lt;p&gt;
That will generate a query and result much like above in DSTrace, but the value held in the node set will be different, which means the XPATH to get the values will be different.&lt;/p&gt;
&lt;p&gt;For the first case, where we used a Query, the nod set is based on the instance document which is where the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1191&quot;&gt;&lt;acronym title=&quot;A user&#039;s current location in an eDirectory tree, as reported by the Novell Client software.&quot;&gt;current context&lt;/acronym&gt;&lt;/a&gt; is, so something like the following (assuming you know the DN of the driver you want to test for and it is stored in the local variable TARGET-DRIVER-DN): &lt;/p&gt;
&lt;p&gt;$ASSOC-QUERY/attr[@attr-name=&quot;DirXML-Associations&quot;]/value/component[(@name=&#039;volume&#039;) and (text()=$TARGET-DRIVER-DN)]/parent::component[@name=&#039;nameSpace&#039;]/text()=&#039;1&#039;&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;if-xpath op=&quot;true&quot;&amp;gt;$ASSOC-QUERY/attr[@attr-name=&quot;DirXML-Associations&quot;]/value/component[@name=&#039;volume&#039;]/text()=$TARGET-DRIVER-DN&amp;lt;/if-xpath&amp;gt;
&amp;lt;if-xpath op=&quot;true&quot;&amp;gt;$ASSOC-QUERY/attr[@attr-name=&quot;DirXML-Associations&quot;]/value/component[@name=&#039;nameSpace&#039;]/text()=&#039;1&#039;&amp;lt;/if-xpath&amp;gt;

&lt;/pre&gt;&lt;p&gt;
This ought to do it in one operation.  Test that the component named volume, with a text of the DN of the target driver local variable, is true and then up a node to the parent, and look for the component named &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/827&quot;&gt;&lt;acronym title=&quot;1. In Novell exteNd, a label associated with the exteNd Director application. The label becomes part of the application&#039;s URL and makes references to application pages unique.2. In ZENworks Server Management, a location in Novell ConsoleOne where you can display and view critical configuration information about your servers. You can then use this information to manage and control the servers on your managed network.&quot;&gt;namespace&lt;/acronym&gt;&lt;/a&gt;, having a value of 1.  That will evaluate true if one of the nodes meets those requirements.&lt;/p&gt;
&lt;p&gt;For a the second case, where the node set contains the values returned by a Source attribute token, although the same basic instance document is returned, the current context is different and instead of being at the top of the instance document, the nodes are just the values (without the attr node above it).  &lt;/p&gt;
&lt;p&gt;Therefore you would have to use different XPATH, in this case it is easier to do it in two XPATH statements, that both need to be true.  &lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;if-xpath op=&quot;true&quot;&amp;gt;$ASSOC-VALS/component[@name=&#039;volume&#039;]/text()=$TARGET-DRIVER-DN&amp;lt;/if-xpath&amp;gt;
&amp;lt;if-xpath op=&quot;true&quot;&amp;gt;$ASSOC-VALS/component[@name=&#039;nameSpace&#039;]/text()=&#039;1&#039;&amp;lt;/if-xpath&amp;gt;

&lt;/pre&gt;&lt;p&gt;
The node set is basically composed of several nodes, one per Value node returned for the user, so you want to check right at the component level, instead of the attr[@attr-name=&quot;DirXML-Associations&quot;] level.&lt;/p&gt;
&lt;p&gt;If you needed to do something with the value of the association, you could select it into a variable with an XPATH that looks something like setting a local variable equal to the XPATH expression, depending on the &lt;/p&gt;
&lt;p&gt;$ASSOC-VALS/component[@name=&#039;path&#039;]/text()&lt;br /&gt;
or&lt;br /&gt;
$ASSOC-QUERY/attr[@attr-name=&quot;DirXML-Associations&quot;]/component[@name=&#039;path&#039;]/text()&lt;/p&gt;
&lt;p&gt;just after you had gotten to the correct node with a test as shown previously.&lt;/p&gt;
 &lt;div class=&quot;og_rss_groups&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;first last og_links&quot;&gt;&lt;a href=&quot;/communities/coolsolutions&quot; class=&quot;og_links&quot;&gt;Cool Solutions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description>
 <comments>http://www.novell.com/communities/node/5845/using-xpath-examine-association-values#comments</comments>
 <category domain="http://www.novell.com/communities/taxonomy/term/6">DirXML</category>
 <category domain="http://www.novell.com/communities/coolsolutions/edirectory">eDirectory</category>
 <category domain="http://www.novell.com/communities/coolsolutions/nim">Identity Manager</category>
 <category domain="http://www.novell.com/communities/product/identitymanager/identitymanager35">Identity Manager 3.5</category>
 <category domain="http://www.novell.com/communities/topic/xpath">XPATH</category>
 <group domain="http://www.novell.com/communities/coolsolutions/ism" xmlns="http://drupal.org/project/og">Identity &amp;amp; Security Management Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions" xmlns="http://drupal.org/project/og">Cool Solutions</group>
 <pubDate>Sun, 08 Nov 2009 09:40:05 -0700</pubDate>
 <dc:creator>geoffc</dc:creator>
 <guid isPermaLink="false">5845 at http://www.novell.com/communities</guid>
</item>
<item>
 <title>Using String Compares in XPATH Statements</title>
 <link>http://www.novell.com/communities/node/6179/using-string-compares-xpath-statements</link>
 <description> &lt;p&gt;Novell Identity Manager supports several languages for manipulating events that come across as XDS documents.  With DirXML 1.x came the use of XML Style sheets (XSLT) which is still supported.  You can still see some rules in XSLT in some of the drivers.   With NSure Identity Manager 2.0 came DirXML Script an XML based language that is very well suited for manipulating events. &lt;/p&gt;
&lt;p&gt;Common across both languages has been the use of the XML path language, XPATH.  One of the biggest issues with using XPATH in Identity Manager installations, is that most documentation and examples are written with a web or &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1482&quot;&gt;&lt;acronym title=&quot;HyperText Markup LanguageThe markup language used to create pages on the World Wide Web. Because HTML uses ASCII text character combinations to code or tag various options, it can be used on a variety of platforms. HTML coding can be used to format text, create lists, insert multimedia, create forms for collecting user input, and create links to other Web locations.HTML is a language for describing page layout in electronic documents such as Web pages, help files, and e-mail messages. HTML can be used in e-mail and news posts to insert images and apply text treatments.&quot;&gt;HTML&lt;/acronym&gt;&lt;/a&gt; focus.  That is all fine and good in the abstract, but when trying to apply it to real world examples in the Identity Manager experience, much of the online documentation is not that helpful.  &lt;/p&gt;
&lt;p&gt;It is always useful to go straight to the source, and look at the RFC for XPATH 1.0.  The RFC can be found at: &lt;a href=&quot;http://www.w3.org/TR/xpath&quot;&gt;http://www.w3.org/TR/xpath&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In order to make XPATH more available and understandable for others, I have been working on a series of articles about interesting things in XPATH, as they relate to Identity Manager.  You can see some of the previous articles at:  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager&quot;&gt;Some thoughts on XPATH in Novell Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/4825/using-global-configuration-values-xpath&quot;&gt;Using Global Configuration Values in XPATH&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/5845/using-xpath-examine-association-values&quot;&gt;Using XPATH to examine Association values&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/5686/cool-tricks-using-xpath-nodesets&quot;&gt;Cool tricks using XPATH on nodesets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/5818/different-attribute-options-identity-manager&quot;&gt;The different attribute options in Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/4262/learning-xpath-idm&quot;&gt;Learning XPATH for IDM &lt;/a&gt;  (This one is not mine, but still a good read!) &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;One of the neat things to do with XPATH is to do some string manipulations that the default DirXML Script token set does not include.  For example, DirXML Script includes a substring token, but that is placement based.  I.e. Substring from position 3 for 12 positions.  This is very useful, but sometimes you want to do a slightly different substring function, say substring before the @ sign in an email address, to get the username part of the email address, or substring after the @ sign to get the domain name for the email address.&lt;/p&gt;
&lt;p&gt;XPATH handily enough has a pair of string functions, substring-before() and substring-after() to help out with this.  Thus, you could have the email address in a local variable EMAIL-ADDRESS and then call the XPATH functions substring-before($EMAIL-ADDRESS,&quot;@&quot;) or substring-after($EMAIL-ADDRESS,&quot;@&quot; to get the information from the email address that we just discussed.&lt;/p&gt;
&lt;p&gt;One big issue to watch out for in XPATH is that the functions are &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/520&quot;&gt;&lt;acronym title=&quot;A program or function that differentiates between capital and non-capitalized letters or words. Something that is not case sensitive would view &#039;novell&#039; and &#039;Novell&#039; as the same word. A case sensitive program would see two different words.&quot;&gt;case sensitive&lt;/acronym&gt;&lt;/a&gt;.  We get a little spoiled, since most string compare/tests in DirXML Script default to being case-insensitive.  That is, a value of &quot;Brian&quot; is the same as &quot;brian&quot;, is the same as &quot;BrAiN&quot; in most cases.  In XPATH, this is not the case.   Usually to get around this I just upper case the two strings I am about to compare while they are in local variables, just to be on the safe side. &lt;/p&gt;
&lt;p&gt;There are a bunch of other string processing functions defined in XPATH 1.0, and some can be very useful, like contains().  A good example on how to use contains() is in this article:&lt;br /&gt;
&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/4825/using-global-configuration-values-xpath&quot;&gt;Using Global Configuration Values in XPATH&lt;/a&gt; where the idea is to use contains() to recreate the &quot;in subtree&quot; test, that we get in DirXML Script for Source DN and Destination DN.  The reason you might need this, is that the &quot;in subtree&quot; test is only applicable to the current objects source or destination DN.  What if you had another object, say a group the user is a member of, and you want to test if the group is in a particular subtree.  You could set the value of the attribute into a local variable, and then test if XPATH of contains($GROUP-DN,&quot;\ACME\GROUPS\HR&quot;) is true or false. &lt;/p&gt;
&lt;p&gt;There are many other functions that are useful like: &lt;/p&gt;
&lt;p&gt;string() which converts the value you give to a string data type.  Usually not necessary, but good to have available.  Like number() that I discussed in: &lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/6109/xpath-and-math&quot;&gt;XPATH and math&lt;/a&gt; it is not always needed, but nice to have!&lt;/p&gt;
&lt;p&gt;concat() which concatenates two strings together.   Takes two strings, and outputs the concatenated string.&lt;/p&gt;
&lt;p&gt;starts-with() is great for finding strings that start with some value.  You could use a &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/3350&quot;&gt;&lt;acronym title=&quot;A regular expression (regex) is a way of describing a string of text using metacharacters or wildcard symbols.&quot;&gt;regular expression&lt;/acronym&gt;&lt;/a&gt; compare in DirXML Script and look for the regex token ^something where the carat symbol (^) indicates it needs to be at the beginning of the string.&lt;/p&gt;
&lt;p&gt;string-length() is very useful, when you are trying to validate data.  If you know the location code from the HR system is always four characters, a very quick test is if the XPATH string-length($LOC-CODE)=4 is true.&lt;/p&gt;
&lt;p&gt;normalize-space() is a great function.  This replaces multiple white spaces with a single one, and strips off leading and trailing white spaces.  Very useful for cleaning up data coming from a &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/540&quot;&gt;&lt;acronym title=&quot;A collection of information organized and presented to serve a specific purpose. (A telephone book is a common database.) A computerized database is an updated, organized file of machine readable information that is rapidly searched and retrieved by computer.The term database is often erroneously referred to as a synonym for a database management system (DBMS). They are not equivalent. A database is a store of data that describe entities and the relationships between the entities. A database management system is the software mechanism for managing that data.&quot;&gt;database&lt;/acronym&gt;&lt;/a&gt; or the like, where a leading space is a valid case, but you would prefer to avoid that.&lt;/p&gt;
&lt;p&gt;substring-before(), substring-after(), and contains() we already talked about above.&lt;/p&gt;
&lt;p&gt;translate() is a function I do not often used, but it is meant to replace certain characters with others, notionally to allow simple case conversion, but is not sophisticated enough to do it for all languages, and so future support is planned for better case conversion.&lt;/p&gt;
&lt;p&gt;One problem with using string functions in XPATH is that you cannot do &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/799&quot;&gt;&lt;acronym title=&quot;Refers to the * and ? characters when used in database searches.&quot;&gt;wildcard&lt;/acronym&gt;&lt;/a&gt; compares.  That is you cannot compare a $VARNAME=test* and expect it to work.  The asterisk (*) is meant for node tests, where a single asterisk (*) means any node of the principal node type of the given axis.  For example, child::* matches any element, attribute::* or @* matches any attribute.&lt;/p&gt;
&lt;p&gt;In the Identity Manager implementations of XPath (which is 1.0, not XPATH 2.0), you can however use methods from java.lang.String that support regular expressions as extension functions, e.g. modify-attr[jstring:matches(@attr-name,&#039;ACMEPROFILE.*&#039;)] (where jstring have been mapped to &lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/nxsl/java/java.lang.String&quot;&gt;http://www.novell.com/nxsl/java/java.lang.String&lt;/a&gt;) or modify-attr[java.lang.String:matches(@attr-name,&#039;ACMEPROFILE.*&#039;)] This is a DirXML Script provided functionality and is not available in XSLT.&lt;/p&gt;
&lt;p&gt;Overall XPATH gets us a lot of functionality, the only real issue is that it is more complex than other approaches.  However it is good to have multiple approaches in your toolkit for when you need it!&lt;/p&gt;
 &lt;div class=&quot;og_rss_groups&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;first last og_links&quot;&gt;&lt;a href=&quot;/communities/coolsolutions&quot; class=&quot;og_links&quot;&gt;Cool Solutions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description>
 <comments>http://www.novell.com/communities/node/6179/using-string-compares-xpath-statements#comments</comments>
 <category domain="http://www.novell.com/communities/taxonomy/term/6">DirXML</category>
 <category domain="http://www.novell.com/communities/coolsolutions/edirectory">eDirectory</category>
 <category domain="http://www.novell.com/communities/coolsolutions/nim">Identity Manager</category>
 <category domain="http://www.novell.com/communities/product/identitymanager/identitymanager35">Identity Manager 3.5</category>
 <category domain="http://www.novell.com/communities/topic/xpath">XPATH</category>
 <group domain="http://www.novell.com/communities/coolsolutions/ism" xmlns="http://drupal.org/project/og">Identity &amp;amp; Security Management Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions" xmlns="http://drupal.org/project/og">Cool Solutions</group>
 <pubDate>Sun, 08 Nov 2009 09:39:55 -0700</pubDate>
 <dc:creator>geoffc</dc:creator>
 <guid isPermaLink="false">6179 at http://www.novell.com/communities</guid>
</item>
<item>
 <title>XPATH and math</title>
 <link>http://www.novell.com/communities/node/6109/xpath-and-math</link>
 <description> &lt;h3&gt;&lt;strong&gt;XPATH and math:&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Novell Identity Manager has several languages supported to process events in the flow of events.  There is the original &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/3186&quot;&gt;&lt;acronym title=&quot;Extensible Markup Language&quot;&gt;XML&lt;/acronym&gt;&lt;/a&gt; Style sheets (XSLT) from the DirXML 1.x days, and with the release of NSure Identity Manager 2.0, DirXML Script got added.  Along the way, the ability to call out to &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1591&quot;&gt;&lt;acronym title=&quot;An object-oriented programming language developed by Sun Microsystems, Inc. to create executable content (ie, self-running applications) that can be easily distributed through networks like the Internet. Developers use Java to create special programs called applets that can be incorporated in web pages to make them interactive. A Java-enabled web browser is required to interpret and run the Java applets.&quot;&gt;Java&lt;/acronym&gt;&lt;/a&gt; classes was maintained, and with the release of Novell Identity Manager 3.5 we got the ability to call out to ECMA Script functions (aka Java Script).&lt;/p&gt;
&lt;p&gt;Throughout all of that we have the ability to use XPATH, the XML Path language in both DirXML Script, XSLT, and I think even ECMA Script.  &lt;/p&gt;
&lt;p&gt;I have been working on a series of articles about XPATH in Novell Identity Manager, and here are some links for the ones I have written so far:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager&quot;&gt;Some thoughts on XPATH in Novell Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/4825/using-global-configuration-values-xpath&quot;&gt;Using Global Configuration Values in XPATH&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/5686/cool-tricks-using-xpath-nodesets&quot;&gt;Cool tricks using XPATH on nodesets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/5845/using-xpath-examine-association-values&quot;&gt;Using XPATH to examine Association values&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/5033/reading-and-displaying-value-java-heap-identity-manager-rules&quot;&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/5907/ism-even-easier-way-call-job-policy&quot;&gt;Reading and Displaying the Value of Java Heap in Identity Manager Rules&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/5846/changes-do-not-require-driver-restart-and-errors-starting-identity-manager-driver&quot;&gt;Changes that do not require a driver restart, and errors on starting an Identity Manager driver&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/5818/different-attribute-options-identity-manager&quot;&gt;The different attribute options in Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;and some other good articles by others:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/4262/learning-xpath-idm&quot;&gt;Learning XPATH for IDM &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.novell.com/communities/node/3499/demystifying-xpath-and-regular-expressions-identity-manager&quot;&gt;Demystifying XPATH and Regular Expressions in Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the article &lt;a href=&quot;http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager&quot;&gt;Some thoughts on XPATH in Novell Identity Manager&lt;/a&gt; I talked about some of the XPATH features we can use in Identity Manager.&lt;/p&gt;
&lt;p&gt;One of the discussions in that article was the difference between selecting a node via XPATH (aka a node test) and doing something, like math, with XPATH. &lt;/p&gt;
&lt;p&gt;There are a couple of caveats to using XPATH for math that are worth thinking about, and once you have thought about them, they are of course very obvious, and easy to remember, but until you spend that moment to think about it, they are somewhat non obvious.&lt;/p&gt;
&lt;p&gt;First off, there is a number() function, that is useful to use, when you want to be sure the value you are about to use is really an integer.  For example, you might use a counter variable in a for-each loop.  In that case, you might initialize it before the loop begins by set local variable COUNTER to the string 0.  Now is that a string or an integer, as far as XPATH is concerned?  In my experience, most of the time, that is sufficient to be treated as an integer.  However, it is easy to be certain, just use the number($COUNTER) function, whenever you use the variable for math. &lt;/p&gt;
&lt;p&gt;Thus inside your for-each loop, you can increment it either as. set local variable equal to the XPATH $COUNTER + 1 or perhaps to be safe the XPATH number($COUNTER) + 1.&lt;/p&gt;
&lt;p&gt;Subtraction is the next issue. From the XML Path language RFC at &lt;a href=&quot;http://www.w3.org/TR/1999/REC-xpath-19991116&quot; title=&quot;http://www.w3.org/TR/1999/REC-xpath-19991116&quot;&gt;http://www.w3.org/TR/1999/REC-xpath-19991116&lt;/a&gt; there is a note.&lt;/p&gt;
&lt;div class=&quot;callout&quot;&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Since XML allows - in names, the - operator typically needs to be preceded by white space. For example, foo-bar evaluates to a node-set containing the child elements named foo-bar; foo - bar evaluates to the difference of the result of converting the string-value of the first foo child element to a number and the result of converting the string-value of the first bar child to a number.&lt;/div&gt;
&lt;p&gt;What that is basically saying is you need a space on either side of your minus sign.  So while it might look like number($COUNTER)-1 should work, you really need to write it as number($COUNTER) - 1 which is a pretty easy thing to accommodate. &lt;/p&gt;
&lt;p&gt;The reasoning being pretty obvious once you read the note.  The dash symbol is valid in variable names, so unless it has spaces to either side, it is not clear to the parser that you mean do math, instead of using it as part of the name.&lt;/p&gt;
&lt;p&gt;Trivial, but non obvious.  In fact, I had stumbled upon this issue in a funny fashion, helping out a friend.  I had suggested the XPATH $COUNTER+1 and that worked, but he was trying to then do subtraction and $COUNTER-1 was not working.  I suggested he try number($COUNTER) - 1 thinking it was the number() function that would do the trick, but as I typed the suggestion, I had put in spaces around the dash (minus sign), without thinking about it, aiming only for clarity.  Turns out I had gotten the correct idea without knowing why.  The joys of learning complicated systems!&lt;/p&gt;
&lt;p&gt;Next up is division.  There is a mod operator, that acts much as you would expect, it returns the remainder from an integer division operation.  I had used that before and had no issues. &lt;/p&gt;
&lt;p&gt;I usually use the mod operator when I want a delay loop, because of &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2211&quot;&gt;&lt;acronym title=&quot;A means of ensuring that replicas of a Novell Directory Services (NDS) partition contain the same information as other replicas of that partition. The update is triggered when properties for an object are added, deleted, moved, or changed.&quot;&gt;replica synchronization&lt;/acronym&gt;&lt;/a&gt;.  That is, an event happens to two objects on one replica in a driver there.  The driver on this second box needs to see the event on both of them before proceeding, so since I cannot guarantee both changes will synchronize at the same time or even close enough, I usually build a test loop. &lt;/p&gt;
&lt;p&gt;The loop uses a counter variable, that runs for a GCV called RetryCount (defined as say 120 or so times) to use the Query token for the needed attribute.  The Query token as described in the article &lt;a href=&quot;http://www.novell.com/communities/node/5920/ism-more-thoughts-sourcedestinationoperation-attribute-tokens-identity-manager&quot;&gt;More thoughts on Source/Destination/Operation attribute tokens in Identity Manager&lt;/a&gt; always checks, and does not read from the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1063&quot;&gt;&lt;acronym title=&quot;1. (verb) To hold data in a temporary storage area, such as in RAM. The data can be accessed more quickly from RAM than from the hard disk.2. (noun) A quickly accessible area of RAM or a directory or a disk that stores frequently used information.3. (noun) On the Web, refers to the area where the browser stores downloaded graphics on the user&#039;s computer. That way, when the user has to reload the graphics, the browser retrieves it from the computer faster than ite would reloading the graphics from the Internet.&quot;&gt;cache&lt;/acronym&gt;&lt;/a&gt;, so it keeps trying to look for the second object.  Then after that first number of loops, I pause for a GCV RetryPauseTime (defined as say 1000 milliseconds), and finally after a GCV RetryMax, (defined as say 601, or 10,000 tries) I exit the loop entirely and decide the second object never appeared.  You can use the mod operator to divide the current counter value by the RetryCount GCV and show the left over.  Whenever it is zero, it is time to take a break for RetryPauseTime.&lt;/p&gt;
&lt;p&gt;Well that was mod, which is nice, now on to division.  Without thinking about it, I tried an XPATH of number($COUNTER)/number($MEM-FREE) in a rule, and the driver refused to start, with the error: &lt;/p&gt;
&lt;pre&gt;DirXML Log Event -------------------
     Driver:   \ACMEIDVAULT\acmeny\services\FLAT\BlockingActions
     Channel:  Subscriber
     Status:   Error
     Message:  Code(-9130) Error in vnd.nds.stream://ACMEIDVAULT/acmeny/services/FLAT/BlockingActions/Subscriber/%5Bacme%5D+acmeEnt
itlementCounter+tools#XmlData:508 : An invalid XPATH expression &#039;number($COUNTER)/number($MEM-FREE)&#039; is specified: java.lang.IllegalArgumentException: DOMEvaluator parser error: a node-test was expected.

&lt;/pre&gt;&lt;p&gt;Here we have the same basic issue.  A node test in XPATH, usually includes the forward slash symbol, which I always think of as division.   But in XPATH it is not division.  Again, completely trivial once you spend a moment to think about it, but not obvious at first glance.&lt;/p&gt;
&lt;p&gt;Turns out the real division operator is div.  Easy enough to fix, change the XPATH number($COUNTER)/number($MEM-FREE) to number($COUNTER) div number($MEM-FREE) and we are good to go.&lt;/p&gt;
&lt;p&gt;Has anyone else run into other similar obvious in hindsight things about XPATH, that are worth mentioning?  Please feel free to comment or write an article about it!  The more the merrier!&lt;/p&gt;
 &lt;div class=&quot;og_rss_groups&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;first last og_links&quot;&gt;&lt;a href=&quot;/communities/coolsolutions&quot; class=&quot;og_links&quot;&gt;Cool Solutions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description>
 <comments>http://www.novell.com/communities/node/6109/xpath-and-math#comments</comments>
 <category domain="http://www.novell.com/communities/taxonomy/term/6">DirXML</category>
 <category domain="http://www.novell.com/communities/coolsolutions/edirectory">eDirectory</category>
 <category domain="http://www.novell.com/communities/coolsolutions/nim">Identity Manager</category>
 <category domain="http://www.novell.com/communities/product/identitymanager/identitymanager35">Identity Manager 3.5</category>
 <category domain="http://www.novell.com/communities/topic/xpath">XPATH</category>
 <group domain="http://www.novell.com/communities/coolsolutions/ism" xmlns="http://drupal.org/project/og">Identity &amp;amp; Security Management Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions" xmlns="http://drupal.org/project/og">Cool Solutions</group>
 <pubDate>Sun, 08 Nov 2009 09:39:49 -0700</pubDate>
 <dc:creator>geoffc</dc:creator>
 <guid isPermaLink="false">6109 at http://www.novell.com/communities</guid>
</item>
<item>
 <title>XPATH and the context node</title>
 <link>http://www.novell.com/communities/node/6175/xpath-and-context-node</link>
 <description> &lt;p&gt;Note:  I wrote another attempt at this that is helpful as well, in trying to explain this concept, you can find the new article at: &lt;a href=&quot;http://www.novell.com/communities/node/6910/another-attempt-explaining-xpath-context-node&quot;&gt;Another Attempt at Explaining the Context Node&quot;&lt;/A&gt;.
&lt;p&gt;Novell Identity Manager allows you to use a number of approaches to manipulate events that occur in the Identity Vault and in the connected systems.&lt;/p&gt;
&lt;p&gt;With the original release of Identity Manager, when it was still called DirXML, the only real option was XSLT.  XSLT is still available and some of the drivers still use it.  XSLT is very powerful when you need to convert the syntax of the document from one XML based dialect to another, which is why the SOAP and Delimited Text drivers use it.  The SOAP driver converts the XDS dialect that Identity Manager uses to the SOAP document dialect (SPML, DSML, or other) that you are trying to communicate with and then in the other direction as needed (Depending on if the event is in the Subscriber (XDS -&amp;gt; SOAP) or Publisher (SOAP -&amp;gt; XDS) channel).&lt;/p&gt;
&lt;p&gt;The Delimited Text driver converts XDS event documents to comma separated values (CSV) and vica versa using XSLT.&lt;/p&gt;
&lt;p&gt;The SAP HR driver requires the use of XSLT in order to format a funny looking Query document that is used to get the relationship between people (Technically Persons, but I find that plural of the word Person funny looking), Jobs, Positions, and Organizations within the HR system.  The query uses nodes that the DTD supports, but are hard if not impossible to do any other way, so XSLT is probably your best approach to using them.&lt;/p&gt;
&lt;p&gt;With NSure Identity Manager 2.0 we got DirXML Script, an XML based language that is used to manipulate events.  With each subsequent release of Identity Manager more features have been added to DirXML Script.  New verbs, tokens, actions, and conditions have been added, as well as interesting enhancements to existing tokens and functions.  You can read more about those new features at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/2209/unique-name-token-functionality-idm-35&quot;&gt;Unique Name Token Functionality in IDM 3.5&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/5687/examples-using-parsedn-token-identity-manager&quot;&gt;Examples of using the ParseDN Token in Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/4906/the-query-token-identity-manager&quot;&gt;The Query token in Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/4857/identity-manager-new-feature-jobs&quot;&gt;Identity Manager new feature: Jobs.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/2572/using-time-tokens-idm-35&quot;&gt;Using the Time Tokens in IDM 3.5&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;One thing that has stayed the same, is that when it comes time to select parts of the document, do math, or call out to external &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1591&quot;&gt;&lt;acronym title=&quot;An object-oriented programming language developed by Sun Microsystems, Inc. to create executable content (ie, self-running applications) that can be easily distributed through networks like the Internet. Developers use Java to create special programs called applets that can be incorporated in web pages to make them interactive. A Java-enabled web browser is required to interpret and run the Java applets.&quot;&gt;Java&lt;/acronym&gt;&lt;/a&gt; classes you need to use XPATH.&lt;/p&gt;
&lt;p&gt;XPATH is a tricky thing, where some parts of it are really easy (Like some of the string and math functions), other parts are pretty straight forward, and things like selecting can be simple in principle but surprisingly tricky in practice. &lt;/p&gt;
&lt;p&gt;One source of information about XPATH is the RFC that defines XPATH:&lt;br /&gt;
&lt;a target=&quot;_blank&quot; href=&quot;http://www.w3.org/TR/1999/REC-xpath-19991116&quot;&gt;http://www.w3.org/TR/1999/REC-xpath-19991116&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The thing is that the RFC does not really provide examples, and most web resources on XPATH are confusing since they focus on using XPATH for &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1482&quot;&gt;&lt;acronym title=&quot;HyperText Markup LanguageThe markup language used to create pages on the World Wide Web. Because HTML uses ASCII text character combinations to code or tag various options, it can be used on a variety of platforms. HTML coding can be used to format text, create lists, insert multimedia, create forms for collecting user input, and create links to other Web locations.HTML is a language for describing page layout in electronic documents such as Web pages, help files, and e-mail messages. HTML can be used in e-mail and news posts to insert images and apply text treatments.&quot;&gt;HTML&lt;/acronym&gt;&lt;/a&gt; document manipulation, which is not obvious how they might apply to XDS event documents.&lt;/p&gt;
&lt;p&gt;Other than that, there are a couple of good sites with some examples:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://wiki.novell.com/index.php/XPATH_Examples&quot; title=&quot;http://wiki.novell.com/index.php/XPATH_Examples&quot;&gt;http://wiki.novell.com/index.php/XPATH_Examples&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://ldapwiki.willeke.com/Wiki.jsp?page=IDMCodeSnippets&quot; title=&quot;http://ldapwiki.willeke.com/Wiki.jsp?page=IDMCodeSnippets&quot;&gt;http://ldapwiki.willeke.com/Wiki.jsp?page=IDMCodeS...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have been trying to write some articles about interesting XPATH tidbits, you can read more at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager&quot;&gt;Some thoughts on XPATH in Novell Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/5686/cool-tricks-using-xpath-nodesets&quot;&gt;Cool tricks using XPATH on nodesets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/5845/using-xpath-examine-association-values&quot;&gt;Using XPATH to examine Association values&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/5818/different-attribute-options-identity-manager&quot;&gt;The different attribute options in Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/4825/using-global-configuration-values-xpath&quot;&gt;Using Global Configuration Values in XPATH&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We still need more I think, so here goes another one.  &lt;/p&gt;
&lt;p&gt;In the article about using XPATH for doing math versus selecting a node in a node set (&lt;a href=&quot;http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager&quot;&gt;Some thoughts on XPATH in Novell Identity Manager&lt;/a&gt;) I discussed a couple of ways you can use XPATH.  What seems to be most confusing to people is where are we starting from, also known as: What is the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1191&quot;&gt;&lt;acronym title=&quot;A user&#039;s current location in an eDirectory tree, as reported by the Novell Client software.&quot;&gt;current context&lt;/acronym&gt;&lt;/a&gt; node.&lt;/p&gt;
&lt;p&gt;What illustrated this for me was using the XPATH Simulator in Designer.  I kept trying to use it, and nothing ever seemed to work.  I was sure I had a valid XPATH selection string, and it should have selected something in the sample document, but I just could not get it to do it.  Finally, I walked through the XML document in the object view, and selected the &amp;lt;output&amp;gt; node, and suddenly results appeared! &lt;/p&gt;
&lt;p&gt;The issue had been all along that what matters most for XPATH in selecting, is the context node.  That is, where are we starting from.  There are a number of selection methods that allow you to specify, anywhere this node occurs, but rarely is that sufficiently fine grained for us in an Identity Manager world. &lt;/p&gt;
&lt;p&gt;For example, a node selection of @src-dn is one of the most common ones I find myself using.  That is, select the value of the XML attribute of the current context node, called src-dn.  The part is so important is the &quot;of the current context node&quot;.&lt;/p&gt;
&lt;p&gt;For example, if you query for some objects, store the returned node-set in a local variable and then want to loop through them and read out the src-dn then of course the XPATH select statement of &quot;@src-dn&quot; will not be useful, it will be selecting the same thing every time, the src-dn of the originating event.&lt;/p&gt;
&lt;p&gt;Thus inside your loop you would be selecting for &quot;$current-node/@src-dn&quot; which leverages a built in local variable for the current node of any looping structure you might be in the middle of.  Thus we specify the context to be the local variable, which comes from the loop, and how it looks as an XML node set depends entirely on what the node set you are looping through looks like.&lt;/p&gt;
&lt;p&gt;The two most common node sets you will encounter in Novell Identity Manager for doing this sort of task are probably the results of a Query token or the result returned from the use of one of the tokens, Source Attribute, Attribute, or Destination Attribute.  (For more on the difference between the three attribute tokens, please read:&lt;br /&gt;
&lt;a href=&quot;http://www.novell.com/communities/node/5818&quot;&gt;The different attribute options in Identity Manager&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.novell.com/communities/node/5920&quot;&gt;More thoughts on Source/Destination/Operation attribute tokens in Identity Manager&lt;/a&gt; ).&lt;/p&gt;
&lt;p&gt;Prior to Identity Manager 3.5, there was no Query token, (for more information see: &lt;a href=&quot;http://www.novell.com/communities/node/4906&quot;&gt;The Query token in Identity Manager&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.novell.com/communities/node/5687&quot;&gt;Examples of using the ParseDN Token in Identity Manager&lt;/a&gt;) and we had to use the Java Command Processor.  The Java Command Processor is still available for use, but not really needed any longer, since the three attribute tokens (Source Attribute, Attribute, and Destination Attribute), and the Query token very nicely wrap it in a trivial to use interface.  That is probably my favorite part of a new Identity Manager version release!  Seeing what thing that was a little tricky in the past, is now wrapped in an easy to use interface instead.  (Unique name is another example of a wrapper of a reasonable amount of logic, based around the query functions, to generate, and then test for Unique names in a directory)&lt;/p&gt;
&lt;p&gt;Regardless of which of the four options you choose to use, the engine in the background will generate a query document.  It will ask the source or destination, depending on what you chose, to find all objects of the class you specify (or don&#039;t specify), that match some condition (or no match specified), and return a list of attributes (or all attributes if none specified).  There are all sorts of interesting ways to tune this, by setting the number of returned values (query-ex functionality, see: &lt;a href=&quot;http://www.novell.com/communities/node/4906&quot;&gt;The Query token in Identity Manager&lt;/a&gt; ), limiting the subtree, or specifying a full DN to return a subset of objects, or a single objects values respectively.  &lt;/p&gt;
&lt;p&gt;The Source Attribute, Attribute, Destination Attribute tokens basically do a query for a specified DN with no match criteria (since we know the DN, the current objects src-dn or dest-dn.  Or in the case of Source and Destination Attribute tokens, we can specify the objects DN or association value) for a specified attribute.&lt;/p&gt;
&lt;p&gt;The query document will look something like:&lt;/p&gt;
&lt;pre&gt;&amp;lt;ndsextra version=&quot;3.5&quot; ndsversion=&quot;8.x&quot;&amp;gt;
  &amp;lt;source&amp;gt;
    &amp;lt;product version=&quot;3.5.10.20070918 &quot;&amp;gt;DirXML&amp;lt;/product&amp;gt;
    &amp;lt;contact&amp;gt;Novell, Inc.&amp;lt;/contact&amp;gt;
  &amp;lt;/source&amp;gt;
  &amp;lt;input&amp;gt;
    &amp;lt;query class-name=&quot;Organizational Unit&quot; dest-dn=&quot;com\acme\People\GA\CN\&quot; scope=&quot;entry&quot;&amp;gt;
      &amp;lt;read-attr attr-name=&quot;Object Class&quot;/&amp;gt;
    &amp;lt;/query&amp;gt;
  &amp;lt;/input&amp;gt;
&amp;lt;/nds&amp;gt;

&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here we have a standard DirXML XDS document.  It is a Query, for a specific &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1955&quot;&gt;&lt;acronym title=&quot;The structure that the network administrator chooses and provides with data in order to create a Novell Directory Services (NDS) object. The types of object classes are the same as the names of the objects themselves. For example, User, Organization, Server, etc.&quot;&gt;object class&lt;/acronym&gt;&lt;/a&gt; (Organitional Unit) against the destination system (which happens to be &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/3276&quot;&gt;&lt;acronym title=&quot;A distributed, replicated naming service that maintains information about and provides access to a list of objects that represent network resources, such as network users, servers, printers, print queues, and applications. The directory is physically stored as a set of database files on a server. If the server hosts file system volumes, these files are on volume sys:. If no volumes are present, the directory is stored on the server&#039;s local disk. eDirectory tightly integrates Novell Security Services for e-commerce (PKI, cryptography, and authentication services), allowing developers to build applications that can be accessed and managed across the entire network through explicit policies.&quot;&gt;eDirectory&lt;/acronym&gt;&lt;/a&gt; in this case, coming from an SAP HR example) for a specific DN (The value of dest-dn) and reading back the Object Class.  (The reason for querying the Object class is because it is a mandatory attribute, even Unknown objects, have an object class of Unknown.  See this article for more discussion on the issue: XXX comment on Father Ramons article about Object Class).&lt;/p&gt;
&lt;p&gt;The response can look something like this: &lt;/p&gt;
&lt;pre&gt;&amp;lt;nds dtdversion=&quot;3.5&quot; ndsversion=&quot;8.x&quot;&amp;gt;
  &amp;lt;source&amp;gt;
    &amp;lt;product version=&quot;3.5.10.20070918 &quot;&amp;gt;DirXML&amp;lt;/product&amp;gt;
    &amp;lt;contact&amp;gt;Novell, Inc.&amp;lt;/contact&amp;gt;
  &amp;lt;/source&amp;gt;
  &amp;lt;output&amp;gt;
    &amp;lt;instance class-name=&quot;Organizational Unit&quot; qualified-src-dn=&quot;dc=com\O=acme\OU=People\OU=GA\OU=CN&quot; src-dn=&quot;\ACME-DEV-AUTH\com\acme\People\GA\CN&quot; src-entry-id=&quot;74056&quot;&amp;gt;
      &amp;lt;attr attr-name=&quot;Object Class&quot;&amp;gt;
        &amp;lt;value timestamp=&quot;1207772827#7&quot; type=&quot;string&quot;&amp;gt;Organizational Unit&amp;lt;/value&amp;gt;
        &amp;lt;value timestamp=&quot;1207772827#8&quot; type=&quot;string&quot;&amp;gt;ndsLoginProperties&amp;lt;/value&amp;gt;
        &amp;lt;value timestamp=&quot;1207772827#9&quot; type=&quot;string&quot;&amp;gt;ndsContainerLoginProperties&amp;lt;/value&amp;gt;
        &amp;lt;value timestamp=&quot;1207772827#10&quot; type=&quot;string&quot;&amp;gt;Top&amp;lt;/value&amp;gt;
      &amp;lt;/attr&amp;gt;
    &amp;lt;/instance&amp;gt;
    &amp;lt;status level=&quot;success&quot;&amp;gt;&amp;lt;/status&amp;gt;
  &amp;lt;/output&amp;gt;
&amp;lt;/nds&amp;gt;

&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In this case, if we were using either the Destination Attribute token, or the Query token we might have generated this query, and be planning on storing its result in a local variable that we set to be of type &quot;nodeset&quot; (as opposed to the default type of &quot;string&quot;).  In that case, lets say we called the local variable CHINA-OU then we can start playing around with some XPATH.&lt;/p&gt;
&lt;p&gt;Now is where it depends how you generated the query.  Lets talk about the Query token first.&lt;/p&gt;
&lt;p&gt;The first simple example is:&lt;br /&gt;
$CHINA-OU/@src-dn to get the object DN in the destination data store.  Now this is a silly example, since we provided it to the query token in the first place, but hey, the point is still valid and would work in other circumstances.&lt;/p&gt;
&lt;p&gt;Then we could test to see if we got any values back, and thus if the object we are looking for actually exists.  In that case, you might use a condition that tests if the following XPATH statement is true:&lt;/p&gt;
&lt;pre&gt;$CHINA-OU/attr[@attr-name=&quot;Organizational Unit&quot;]/value&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;That tests for the attr node, in the CHINA-OU node set, that has an XML attribute attr-name, that is equal to Organizational Unit, and then tests to see if there is a value node under it.  If there is, it returns true, if there isn&#039;t (no value returned) then it would be false.  &lt;/p&gt;
&lt;p&gt;Thus you can test for the existence of an object. &lt;/p&gt;
&lt;p&gt;The key point to take out of this is that we did not specify a XPATH path (was that redundant or what?  Like &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2169&quot;&gt;&lt;acronym title=&quot;random access memoryThe internal dynamic storage of a computer that can be addressed by the computer&#039;s operating system. RAM is erased when the power is turned off.&quot;&gt;RAM&lt;/acronym&gt;&lt;/a&gt; memory?) that was complex like:&lt;/p&gt;
&lt;pre&gt;$CHINA-OU/nds/output/instance/attr/[@attr-name=&quot;Organizational Unit&quot;]/value&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;it was sufficient to know that the context node for this type of operation in Identity Managers view of XPATH is to start at the node under the output document.&lt;/p&gt;
&lt;p&gt;If we had used the Destination Attribute token, and set a local variable to a node set of the results, what we would have in the nodeset would actually be the set of the value nodes.  I do not think we would be able to get the @src-dn out of the document, since we would really only have the value nodes in memory.  &lt;/p&gt;
&lt;p&gt;Thus we could use a For Each loop on this nodeset, (That is, when you use the for-each action, the node set is the local variable CHINA-OU) and inside the loop, you could XPATH select things $current-node/text() to get the value of  each node as you loop through it, or perhaps test in an IF-THEN test, if $current-node[type=&quot;string&quot;] to get the string values only.  This example seems kind of silly, but actually has utility when looking at Group memberships in systems that do not maintain referential integrity (like Lotus Notes).  In those cases, the driver and engine will try and convert the values it is getting from the destination data store for members names, into DN&#039;s in eDirectory.  Which would by @type=&quot;dn&quot; but since the destination actually could care less what value is stored in that field, (it is basically a free form string field in Lotus Notes/Domino) the values that come back may not be valid DN&#039;s in eDirectory, or may not be associated yet.  You might need to pull out those values to do something with them (like storing them in a multi valued attribute that is string syntax on the group object, or maybe you just want to clean them up, so you would strip them from the operation document with Strip by XPATH expression).&lt;/p&gt;
&lt;p&gt;The case of a Query token can be more interesting, where you can return information about multiple objects, for multiple attributes, of which some might be multi-valued attributes.  In order to take advantage of all the data you retrieved and get all the bits and pieces you want out of the results, you might need to have three nested for-each loops.  &lt;/p&gt;
&lt;p&gt;For a Query document that looks like:&lt;/p&gt;
&lt;pre&gt;&amp;lt;nds dtdversion=&quot;3.5&quot; ndsversion=&quot;8.x&quot;&amp;gt;
  &amp;lt;source&amp;gt;
    &amp;lt;product version=&quot;3.5.10.20070918 &quot;&amp;gt;DirXML&amp;lt;/product&amp;gt;
    &amp;lt;contact&amp;gt;Novell, Inc.&amp;lt;/contact&amp;gt;
  &amp;lt;/source&amp;gt;
  &amp;lt;input&amp;gt;
    &amp;lt;query class-name=&quot;User&quot; dest-dn=&quot;com\acme\People&quot; scope=&quot;subtree&quot;&amp;gt;
      &amp;lt;search-class class-name=&quot;User&quot;/&amp;gt;
      &amp;lt;read-attr&amp;gt;
      	&amp;lt;value&amp;gt;
      &amp;lt;/read-attr&amp;gt;
    &amp;lt;/query&amp;gt;
  &amp;lt;/input&amp;gt;
&amp;lt;/nds&amp;gt;

&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This would return all User objects in the People.acme.com container in the tree, so it could be one or it could be thousands, use with care!  If you return too many values be aware you may run out of Java heap memory.  (For thoughts on how much memory a node set takes up, look at these articles: &lt;a href=&quot;http://www.novell.com/communities/node/6085&quot;&gt;More thoughts on the size of a node set in Identity Manager&lt;/a&gt; but suffice it to say, expect about 10K a node to be on the safe side.  You can check how much Java heap you have allocated, free, and the maximum values by looking at the examples in this article: &lt;a href=&quot;http://www.novell.com/communities/node/5033&quot;&gt;Reading and Displaying the Value of Java Heap in Identity Manager Rules&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Now what you will get back is a nodeset with an &amp;lt;instance&amp;gt; document for each object it found.&lt;/p&gt;
&lt;p&gt;Inside the &amp;lt;instance&amp;gt; node, there will be an XML attribute  src-dn=&quot;TREE\O\OU\OU\ObjectName&quot;, and then underneath the &amp;lt;instance&amp;gt; node there will be a series of &amp;lt;attr&amp;gt; nodes with an XML attribute attr-name=&quot;Attribute Name&quot;.  Underneath the &amp;lt;attr&amp;gt; node will be either a single &amp;lt;value&amp;gt; node or many &amp;lt;value&amp;gt; nodes at the same level, for multi valued attributes.&lt;/p&gt;
&lt;p&gt;You can see how you would need to use three nested for-each loops to get at everything in the query results.&lt;/p&gt;
&lt;p&gt;As before, we set a node set local variable called BIGGER-QUERY with the value of that query shown above, and so our first for-each loops nodeset will be the local variable BIGGER-QUERY.  (We could have said XPATH of $BIGGER-QUERY which would be the same thing).  &lt;/p&gt;
&lt;p&gt;Now in this loop, we can do things like set a local variable CURRENT-USER to the XPATH $current-node/@src-dn to store the user&#039;s DN for use inside all the nested loops.&lt;/p&gt;
&lt;p&gt;This first for each loop would run through all the instance documents, one per User object found, until they are all done. &lt;/p&gt;
&lt;p&gt;Then we would have another for-each loop inside the first one, to loop through the nodeset of either local variable current-node or XPATH $current-node.&lt;/p&gt;
&lt;p&gt;We can test in this loop if the $current-node (now the local value of this loops current node), is $current-node/attr[@attr-name=&quot;Some Attribute&quot;] and possibly do something with the value.&lt;/p&gt;
&lt;p&gt;If the attribute is multi valued, then there will be several &amp;lt;value&amp;gt; nodes inside the &amp;lt;attr&amp;gt; node, so we would need a third for each loop to work through that set as well. &lt;/p&gt;
&lt;p&gt;The nodeset for our third for each loop would be XPATH of $current-node/value and we could test again like above for @type=&quot;string&quot; or the like.  Perhaps we want to build a text string to send in an Audit event or an email or something else like that.&lt;/p&gt;
&lt;p&gt;Hopefully this example shows pretty simply how the context node matters, and everything is based on where it currently is, when using XPATH.&lt;/p&gt;
&lt;p&gt;I think I will need to continue on this thread, and possibly take another swing at it with more examples.  Hmm.&lt;/p&gt;
 &lt;div class=&quot;og_rss_groups&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;first last og_links&quot;&gt;&lt;a href=&quot;/communities/coolsolutions&quot; class=&quot;og_links&quot;&gt;Cool Solutions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description>
 <comments>http://www.novell.com/communities/node/6175/xpath-and-context-node#comments</comments>
 <category domain="http://www.novell.com/communities/taxonomy/term/6">DirXML</category>
 <category domain="http://www.novell.com/communities/coolsolutions/edirectory">eDirectory</category>
 <category domain="http://www.novell.com/communities/coolsolutions/nim">Identity Manager</category>
 <category domain="http://www.novell.com/communities/product/identitymanager/identitymanager35">Identity Manager 3.5</category>
 <category domain="http://www.novell.com/communities/topic/xpath">XPATH</category>
 <group domain="http://www.novell.com/communities/coolsolutions/ism" xmlns="http://drupal.org/project/og">Identity &amp;amp; Security Management Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions" xmlns="http://drupal.org/project/og">Cool Solutions</group>
 <pubDate>Sun, 08 Nov 2009 09:39:44 -0700</pubDate>
 <dc:creator>geoffc</dc:creator>
 <guid isPermaLink="false">6175 at http://www.novell.com/communities</guid>
</item>
<item>
 <title>Some thoughts on XPATH in Novell Identity Manager</title>
 <link>http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager</link>
 <description> &lt;p&gt;The original iteration of Novell&#039;s product started as DirXML 1 and (when it was still called Virtual Replicas, thus the engine&#039;s name as a &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/508&quot;&gt;&lt;acronym title=&quot;1. The name of the number system in which there are only zeros and ones. This is important to computers because all computer data is ultimately a series of zeros and ones, and thus can be represented by binary numbers.2. Data that is not meant to be intepreted through a common character set (like ASCII). Pure binary data is typically 8-bit data. Transferring a binary file through ASCII channels without prior modification will result in corruption and loss of data. Binary data can be turned into ASCII data via uucoding or bcoding.&quot;&gt;binary&lt;/acronym&gt;&lt;/a&gt; is still &quot;vrdim&quot; internal to the system.&lt;/p&gt;
&lt;p&gt;In that build, all work was done in XSLT, the XML Style sheet Transformation language.  &lt;/p&gt;
&lt;p&gt;With the release of NSure Identity Manager 2.0 (gotta love the name changes) DirXML Script was introduced, which is an XML dialect that specifies conditions, actions, nouns, verbs, and tokens in a reasonably easy to read syntax that has an astonishing amount of power.&lt;/p&gt;
&lt;p&gt;With each release of new versions of Identity Manager the functionality of DirXML Script gets better and better.  Examples are things like the Unique Name (&lt;a href=&quot;http://www.novell.com/communities/node/2209/unique-name-token-functionality-idm-35&quot;&gt;http://www.novell.com/communities/node/2209/unique-name-token-functionality-idm-35&lt;/a&gt;), Time, and Convert Time tokens (&lt;a href=&quot;http://www.novell.com/communities/node/2572/using-time-tokens-idm-35&quot;&gt;http://www.novell.com/communities/node/2572/using-time-tokens-idm-35&lt;/a&gt;).  In both cases, you could do all the work in a rule you wrote yourself (for the case of Unique Name) or via a call to a &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1591&quot;&gt;&lt;acronym title=&quot;An object-oriented programming language developed by Sun Microsystems, Inc. to create executable content (ie, self-running applications) that can be easily distributed through networks like the Internet. Developers use Java to create special programs called applets that can be incorporated in web pages to make them interactive. A Java-enabled web browser is required to interpret and run the Java applets.&quot;&gt;Java&lt;/acronym&gt;&lt;/a&gt; class (Time and Convert Time).  But the thing was, pretty much everybody needed to use one of these tokens in a project, so why not build a nice interface around it (Time and Convert Time&#039;s interface versus the call to a Java class is such an improvement it is amazing to see!  The Java time function is very very powerful, and the Time/Convert Time tokens expose most of it in a trivial to use fashion.).&lt;/p&gt;
&lt;p&gt;XSLT is still here and supported in the latest versions of Novell Identity Manager, and in fact some drivers still use it by default, because what it does, is still not one hundred percent replicated by DirXML Script, or perhaps more correctly, XSLT is better suited to do the task.  Examples are parts of the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2279&quot;&gt;&lt;acronym title=&quot;1. Service Advertising Protocol: A protocol used by NetWare Loadable Modules (NLMs) to inform clients of a server&#039;s presence. Servers advertise their services, by both name and type, with Service Advertising Protocol (SAP), allowing routers to create and maintain a database of current internetwork server information. This information goes to all nodes on an IPX network.2. service access point: A virtual port on a data link adapter. A SAP provides communication points between adjacent local area network (LAN) protocol layers. A SAP is referred to by a three-digit hexadecimal number.3. secondary audio program.&quot;&gt;SAP&lt;/acronym&gt;&lt;/a&gt; HR/UAM drivers, where there is an external relationship between objects that is almost impossible (or so the original author told me in person, and that he had asked the worlds greatest expert on DirXML Script take on the task, before admitting it was currently impossible.  If Father Ramon believed it could not be done in DirXML Script then it cannot be done) to do in DirXML Script.  &lt;/p&gt;
&lt;p&gt;The other example is the Delimited Text driver, which takes an incoming file CSV style file and performs a transform into an XDS formatted document.  This is exactly the type of thing XSLT is designed for, and it truly shines in this space.  &lt;/p&gt;
&lt;p&gt;Having said that, most drivers use minimal XSLT these days as DirXML Script has become powerful enough to do almost everything needed.&lt;/p&gt;
&lt;p&gt;If you cannot do it in DirXML Script, you have two more options, before falling back to XSLT.  Call out to a custom Java class that you wrote to perform the specific task, or use XPATH.  The scope of things you can do within your custom Java class is limited by your imagination and your access to &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2636&quot;&gt;&lt;acronym title=&quot;application programming interfaceA set of functions, procedures, values, or other defined interface standards that an application uses to request and carry out services performed by another program or by an operating system. A single API typically specifies how input should be requested and obtained, and how output should be done.&quot;&gt;API&lt;/acronym&gt;&lt;/a&gt;&#039;s.&lt;/p&gt;
&lt;p&gt;XPATH is the XML Path Language, and a good definition of the RFC is at this link:&lt;br /&gt;
&lt;a href=&quot;http://www.w3.org/TR/1999/REC-xpath-19991116&quot;&gt;http://www.w3.org/TR/1999/REC-xpath-19991116&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What is nice about this link is that you can find functions that are supported by XPATH in an XPATH statement.  It is worth mentioning that Novell Identity Manager only supports XPATH 1.0 and not XPATH 2.0.  The issue of 2.0 support is a complex one, since apparently XPATH 2.0 is not backwards compatible with XPATH 1.0, and thus an upgrade of support to 2.0 could cause you to have to re-evaluate all the use of XPATH in your current drivers.  Clearly this is NOT a customer friendly event to consider.  I will be interested in seeing how Novell intends to handle this issue in the future, as it will no doubt become more pressing.&lt;/p&gt;
&lt;p&gt;XPATH, like XSLT is relatively confusing, and reading the RFC is not always enlightening.  There are a bunch of Identity Manager focused resources you can look at, the Support forums (forums.novell.com over &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1484&quot;&gt;&lt;acronym title=&quot;Hypertext Transfer ProtocolThe protocol that Web servers and Web browsers use to communicate with each other on the World Wide Web (WWW). Web browsers submit HTTP requests; Web servers use HTTP to respond with the requested document.&quot;&gt;HTTP&lt;/acronym&gt;&lt;/a&gt; or &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1888&quot;&gt;&lt;acronym title=&quot;Network News Transfer ProtocolThe basic Internet protocol used to exchange network news articles between multiple news servers and between news servers and newsreaders.&quot;&gt;NNTP&lt;/acronym&gt;&lt;/a&gt;) to start with.  There are lots of examples floating in previous message posts in that group.  There are some Wiki sites with samples like:&lt;br /&gt;
&lt;a href=&quot;http://wiki.novell.com/index.php/XPATH_Examples&quot;&gt;http://wiki.novell.com/index.php/XPATH_Examples&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://ldapwiki.willeke.com/Wiki.jsp?page=IDMCodeSnippets&quot;&gt;http://ldapwiki.willeke.com/Wiki.jsp?page=IDMCodeSnippets&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;One issue that I find stalls many first timers as they encounter XPATH is the difference between selecting and evaluating.  &lt;/p&gt;
&lt;p&gt;XPATH is used in two very different contexts within an Identity Manager solution.&lt;/p&gt;
&lt;p&gt;The most common use is to select a node in an XML document.  The second usage is to call some function or do something with XPATH.  Both approaches use the same language but are very different and confusing.&lt;/p&gt;
&lt;p&gt;Selecting a node with an XML document (in the XDS dialect for Identity Manager) you can use the XPATH simulator in Designer pretty effectively.  &lt;/p&gt;
&lt;p&gt;Here is a sample of an add User document, and some of the things you can use XPATH to easily select.&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;nds dtdversion=&quot;3.5&quot; ndsversion=&quot;8.x&quot;&amp;gt;
  &amp;lt;source&amp;gt;
    &amp;lt;product version=&quot;3.5.10.20070918 &quot;&amp;gt;DirXML&amp;lt;/product&amp;gt;
    &amp;lt;contact&amp;gt;Novell, Inc.&amp;lt;/contact&amp;gt;
  &amp;lt;/source&amp;gt;
  &amp;lt;input&amp;gt;
    &amp;lt;modify class-name=&quot;User&quot; dest-dn=&quot;\ACME-TREE\LAB\EMPLOYEES\ACTIVE\ljohnson&quot; dest-entry-id=&quot;61535&quot; event-id=&quot;ACMESMSLES10FS1#20080515175150#1#1&quot; from-merge=&quot;true&quot; qualified-src-dn=&quot;O=acme\OU=NYC\OU=FIN\CN=ljohnson&quot; src-dn=&quot;acme\NYC\FIN\ljohnson&quot; src-entry-id=&quot;34296&quot;&amp;gt;
      &amp;lt;association&amp;gt;{50BCE1E7-2D5F-dc01-80C5-330003000000}&amp;lt;/association&amp;gt;
      &amp;lt;modify-attr attr-name=&quot;Password Expiration Time&quot;&amp;gt;
        &amp;lt;remove-all-values/&amp;gt;
      &amp;lt;/modify-attr&amp;gt;
      &amp;lt;modify-attr attr-name=&quot;Login Time&quot;&amp;gt;
        &amp;lt;remove-all-values/&amp;gt;
      &amp;lt;/modify-attr&amp;gt;
      &amp;lt;modify-attr attr-name=&quot;GUID&quot;&amp;gt;
        &amp;lt;remove-all-values/&amp;gt;
      &amp;lt;/modify-attr&amp;gt;
      &amp;lt;modify-attr attr-name=&quot;NOVUser&quot;&amp;gt;
        &amp;lt;add-value&amp;gt;
          &amp;lt;value timestamp=&quot;1210875960#2&quot; type=&quot;state&quot;&amp;gt;false&amp;lt;/value&amp;gt;
        &amp;lt;/add-value&amp;gt;
      &amp;lt;/modify-attr&amp;gt;
      &amp;lt;modify-attr attr-name=&quot;Password Expiration Time&quot;&amp;gt;
        &amp;lt;add-value&amp;gt;
          &amp;lt;value timestamp=&quot;1210341755#17&quot; type=&quot;time&quot;&amp;gt;1189381168&amp;lt;/value&amp;gt;
        &amp;lt;/add-value&amp;gt;
      &amp;lt;/modify-attr&amp;gt;
      &amp;lt;modify-attr attr-name=&quot;GUID&quot;&amp;gt;
        &amp;lt;add-value&amp;gt;
          &amp;lt;value timestamp=&quot;1210341755#41&quot; type=&quot;octet&quot;&amp;gt;gA8kk9Ad3RGIhwBQVrsTEw==&amp;lt;/value&amp;gt;
        &amp;lt;/add-value&amp;gt;
      &amp;lt;/modify-attr&amp;gt;
    &amp;lt;/modify&amp;gt;
  &amp;lt;/input&amp;gt;
&amp;lt;/nds&amp;gt;

&lt;/pre&gt;&lt;p&gt;
It depends how you are using the XPATH to understand the context.  For example, you might want to store a local variable with the DN of the source user.  (Now this is not usually needed since there is a Source DN() token in Argument Builder, and an if-source-dn test in the Conditions section, but imagine you needed to do so.).  You could set a local variable to the XPATH statement &quot;@src-dn&quot; which will select the value of src-dn in the modify node (acme\NYC\FIN\ljohnson).  Lets say you called the variable SOURCE-DN.  &lt;/p&gt;
&lt;p&gt;You might have a condition with XPATH as the test.  This can be XPATH is true or is not-true.  Then you might want to say &#039;if XPATH expression is true &quot;@src-dn&quot;&#039; to test if there is a value for src-dn in the document.  (As you may already know, not every document comes across with a src-dn or dest-dn set, and sometimes you need to be sure it is present before you try to use the value, with blind trust that it exists).  This will return true if there is a value, and false if there is no value.&lt;/p&gt;
&lt;p&gt;Those were a couple of examples of using selection.  Now for an example of actions or functionality, lets say you might want to do a in-subtree test against a variable.  In that case, you could use the XPATH function contains().  You really should for our example use the if-sourceDN condition in Policy Builder, and the in-subtree test, but for the purpose of our contrived example lets assume you want to do it the hard way.  One realistic scenario would be when the object path you want to check is not the current object, but your retrieved the path somehow, say via a Distinguished Name syntax attribute, or maybe via a Query for the object.  The Source DN and Destination DN condition tests only really apply to the object that is the focus of the current operational document.&lt;/p&gt;
&lt;p&gt;First off it helps to know that variables can be used in XPATH by referencing them with a dollar sign ($) before the name.   &lt;/p&gt;
&lt;p&gt;You could then test if XPATH expression is true, contains($SOURCE-DN,&quot;ACME\NY\FIN&quot;) and expect either a true of false.  If you wanted too you could use a Global Configuration Value as well, see this article &lt;a href=&quot;http://www.novell.com/communities/node/4825/using-global-configuration-values-xpath&quot;&gt;http://www.novell.com/communities/node/4825/using-global-configuration-values-xpath&lt;/a&gt; for more details on that issue.&lt;/p&gt;
&lt;p&gt;The easiest way I know of in Identity Manager to do math is in XPATH.  I would set a local variable equal to an XPATH expression, and you can use variables and do basic math things.  Like $TIME has the value of the current time in CTIME (Seconds since 1970) but I need 90 days from now.  So I could set the local variable FUTURE-DATE to the XPATH of &quot;$NOW + 90*24*60*60&quot;.  If I am not sure it is really an integer in my variable, I could use the function number() to convert it an integer.&lt;/p&gt;
&lt;p&gt;I could have used a GCV to hold the value of 90 * 24 * 60 *60 or maybe a GCV (lets call it DaysInactive) for the 90 and multiply it by 86400 (seconds in a day, 24 * 60 * 60).  Which would look more like XPATH of &quot;$NOW + ~DaysInactive~*86400&quot;.&lt;/p&gt;
&lt;p&gt;String manipulation can be done in XPATH as well.  While DirXML Script has a very powerful Replace All, Replace First, and Substring tokens, it does not do a good job of substring-before and substring-after, which XPATH supports.&lt;/p&gt;
&lt;p&gt;Imagine you need to get the first part of a users email address, say the part before the @acme.com in &lt;a href=&quot;mailto:ljohnson@acme.com&quot;&gt;ljohnson@acme.com&lt;/a&gt;.  While you could use a Regular Expression to replace everything up to the @ symbol with nulls.   Something like .+\@ will select everything up to @ symbol.  But it is much easier to use the substring-after() XPATH function, so that my variable $EMAIL which holds the value &lt;a href=&quot;mailto:ljohnson@acme.com&quot;&gt;ljohnson@acme.com&lt;/a&gt;, I could set the local variable $NAME equal to the XPATH statement of &quot;substring-after($EMAIL,&quot;@&quot;) and you would end up with what you wanted.&lt;/p&gt;
&lt;p&gt;There are a number of XPATH functions you can use, like concat(), starts-with(), substring-before(), substring-after(), substring(), string-length(), normalize-space(), and translate().  Check the XPATH reference at &lt;a href=&quot;http://www.w3.org/TR/1999/REC-xpath-19991116&quot;&gt;http://www.w3.org/TR/1999/REC-xpath-19991116&lt;/a&gt; that I mentioned above for more XPATH possibilities.&lt;/p&gt;
&lt;p&gt;Normalize-space() is one of my favorites and it is quite powerful and useful for cleaning up strings.  It will replace any multiple occurrences of white space with a single space, and removing any leading and trailing spaces.  Great if you do not trust the exact syntax of the string you are getting from your connected system.  If you are doing string compares, the safest way to be sure they actually compare correctly when you want them too is to normalize-space both of them before you do the compare.&lt;/p&gt;
 &lt;div class=&quot;og_rss_groups&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;first last og_links&quot;&gt;&lt;a href=&quot;/communities/partners/ism&quot; class=&quot;og_links&quot;&gt;Identity and Security&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description>
 <comments>http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager#comments</comments>
 <category domain="http://www.novell.com/communities/taxonomy/term/6">DirXML</category>
 <category domain="http://www.novell.com/communities/coolsolutions/edirectory">eDirectory</category>
 <category domain="http://www.novell.com/communities/coolsolutions/nim">Identity Manager</category>
 <category domain="http://www.novell.com/communities/product/identitymanager/identitymanager35">Identity Manager 3.5</category>
 <category domain="http://www.novell.com/communities/topic/xpath">XPATH</category>
 <group domain="http://www.novell.com/communities/coolsolutions/ism" xmlns="http://drupal.org/project/og">Identity &amp;amp; Security Management Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions" xmlns="http://drupal.org/project/og">Cool Solutions</group>
 <group domain="http://www.novell.com/communities/partners/ism" xmlns="http://drupal.org/project/og">Identity and Security</group>
 <pubDate>Sun, 08 Nov 2009 09:39:10 -0700</pubDate>
 <dc:creator>geoffc</dc:creator>
 <guid isPermaLink="false">4833 at http://www.novell.com/communities</guid>
</item>
<item>
 <title>Using XPATH to Get the Position of a Node in a Node Set</title>
 <link>http://www.novell.com/communities/node/6276/using-xpath-get-position-node-node-set</link>
 <description> &lt;p&gt;Using XPATH to get the position of a &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1889&quot;&gt;&lt;acronym title=&quot;1. End point of a network connection. A node can be any device, such as a file server, router, modem, printer, or workstation, attached to a network.2. In ZENworks Desktop Management and ZENworks Server Management, a clustered server; in other words, a single NetWare server that is part of a cluster. The first node to join the cluster is the master node.&quot;&gt;node&lt;/acronym&gt;&lt;/a&gt; in a node set:&lt;/p&gt;
&lt;p&gt;Novell Identity Manager is a great tool.  Lots of power, and several interesting languages are available for use.&lt;/p&gt;
&lt;p&gt;There is &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/3186&quot;&gt;&lt;acronym title=&quot;Extensible Markup Language&quot;&gt;XML&lt;/acronym&gt;&lt;/a&gt; Style sheets (XSLT) that were the first available language in DirXML 1.0.  You could always call out to a &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1591&quot;&gt;&lt;acronym title=&quot;An object-oriented programming language developed by Sun Microsystems, Inc. to create executable content (ie, self-running applications) that can be easily distributed through networks like the Internet. Developers use Java to create special programs called applets that can be incorporated in web pages to make them interactive. A Java-enabled web browser is required to interpret and run the Java applets.&quot;&gt;Java&lt;/acronym&gt;&lt;/a&gt; class, so that was not all that limiting.  &lt;/p&gt;
&lt;p&gt;With the advent of NSure Identity Manager 2.0 we got access to DirXML Script, which is a great XML based language for processing XML documents.  It is very readable and makes sense (in English only, sorry) to read, because the tokens, verbs, and nouns are all nicely described by their definition.  &lt;/p&gt;
&lt;p&gt;Probably the greatest strength about the DirXML Script is actually the interface that parses it, Policy Builder.  There are currently two different implementations of it, one in &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2869&quot;&gt;&lt;acronym title=&quot;Novell iManagerA browser-based management utility included with NetWare 6. In ZENworks Server Management, it enables administrators to manage Tiered Electronic Distribution (TED) objects, agents, and processes from any location where the required version of Internet Explorer is available.&quot;&gt;iManager&lt;/acronym&gt;&lt;/a&gt;, and the other in Designer for Identity Manager.  &lt;/p&gt;
&lt;p&gt;I personally like the Designer interface better, but that is more of a preference for the widgets and the responsiveness of a thick client (Eclipse based) versus a web application, that is always, by definition, a little slower to respond. &lt;/p&gt;
&lt;p&gt;Both are great, and what is often most powerful is that use the interface to design the rule in general.  Then when you realize you need to make minor changes, you can easily flip over to the XML view and copy and paste, or edit something minor (or major) faster than you could in the interface.  The best of both worlds.&lt;/p&gt;
&lt;p&gt;One of the features both XSLT and DirXML Script offer is the ability to use the XML Path language (XPATH).  The problem is Novell Identity Manager only supports XPATH 1.0, not the newer 2.0 standard, which means many searches for XPATH help will return 2.0 functions or ideas, that will not work in XPATH 1.0.&lt;/p&gt;
&lt;p&gt;Additionally, the way Identity Manager uses XPATH is slightly different from how standard XPATH is implemented.  (Usually related to the context node (see: &lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/6175/xpath-and-context-node&quot;&gt;XPATH and the context node&lt;/a&gt;)).  This sometimes makes it hard to translate web XPATH examples into Identity Manager examples.  &lt;/p&gt;
&lt;p&gt;Additionally you do not see a lot of articles about really cool ways to use XPATH in Identity Manager.  Thus I was looking to add more articles on the issue to the public mix.&lt;/p&gt;
&lt;p&gt;One source of information about XPATH is the RFC that defines XPATH:&lt;br /&gt;
&lt;a target=&quot;_blank&quot; href=&quot;http://www.w3.org/TR/1999/REC-xpath-19991116&quot;&gt;http://www.w3.org/TR/1999/REC-xpath-19991116&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The thing is that the RFC does not really provide examples, and most web resources on XPATH are confusing since they focus on using XPATH for &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1482&quot;&gt;&lt;acronym title=&quot;HyperText Markup LanguageThe markup language used to create pages on the World Wide Web. Because HTML uses ASCII text character combinations to code or tag various options, it can be used on a variety of platforms. HTML coding can be used to format text, create lists, insert multimedia, create forms for collecting user input, and create links to other Web locations.HTML is a language for describing page layout in electronic documents such as Web pages, help files, and e-mail messages. HTML can be used in e-mail and news posts to insert images and apply text treatments.&quot;&gt;HTML&lt;/acronym&gt;&lt;/a&gt; document manipulation, which is not obvious how they might apply to XDS event documents.&lt;/p&gt;
&lt;p&gt;Other than that, there are a couple of good sites with some examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://wiki.novell.com/index.php/XPATH_Examples&quot;&gt;http://wiki.novell.com/index.php/XPATH_Examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ldapwiki.willeke.com/Wiki.jsp?page=IDMCodeSnippets&quot;&gt;http://ldapwiki.willeke.com/Wiki.jsp?page=IDMCodeSnippets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I have been trying to write some articles about interesting XPATH tidbits, you can read more at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/4833/some-thoughts-xpath-novell-identity-manager&quot;&gt;Some thoughts on XPATH in Novell Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/5686/cool-tricks-using-xpath-nodesets&quot;&gt;Cool tricks using XPATH on nodesets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/5845/using-xpath-examine-association-values&quot;&gt;Using XPATH to examine Association values&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/5818/different-attribute-options-identity-manager&quot;&gt;The different attribute options in Identity Manager&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/4825/using-global-configuration-values-xpath&quot;&gt;Using Global Configuration Values in XPATH&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/6175/xpath-and-context-node&quot;&gt;XPATH and the context node&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We still need more I think, so here goes another one.  &lt;/p&gt;
&lt;p&gt;I was reading a neat web site called Stack Overflow, (&lt;a href=&quot;http://www.stackoverflow.com&quot; title=&quot;www.stackoverflow.com&quot;&gt;www.stackoverflow.com&lt;/a&gt;) and looked for this interesting XPATH example I thought I would liberate (Information wants to be free after all, right?)&lt;br /&gt;
&lt;a target=&quot;_blank&quot; href=&quot;http://stackoverflow.com/questions/226405/find-position-of-a-node-using-xpath&quot;&gt;http://stackoverflow.com/questions/226405/find-position-of-a-node-using-xpath&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When referring to a node set, it is possible to specify a couple of interesting XPATH descriptors to specify it by the node placement.&lt;/p&gt;
&lt;p&gt;That is, if you are using an Append XML element, you need to specify an XPATH location for it.  So you could say add-attr[@attr-name=&quot;Group Membership&quot;]/value[2] to refer to the second node in the set of values.  Or you could append it to the end with add-attr[@attr-name=&quot;Group Membership&quot;]/value/last() or insert at the beginning, with add-attr[@attr-name=&quot;Group Membership&quot;]/value/first() and whatnot.&lt;/p&gt;
&lt;p&gt;But what if you want to know what place the node is in the list of values, how would you do figure it out via XPATH?   I think I know how I would do it by looping through the node set in a for-each loop, using a counter value, and testing each value for the one I want and returning the counter value when done.&lt;/p&gt;
&lt;p&gt;If this is a really large node set, then it probably is not very efficient to loop through the node set, and would be really cool to just do it in a magical XPATH statement.&lt;/p&gt;
&lt;p&gt;Now to be fair, I am having trouble deciding when I would want to actually know this info in an Identity Manager context, since most multi valued attributes that are returned, while they look ordered, usually are not.  Often they do not return the values in a predictable order, though they ought to return in the same order each time (as long as you use the same replica).  (I.e. Usually not alphabetic, usually by the order it was added as a value).  But I think it is an interesting exercise regardless.  Ok, I&#039;ll admit it, I thought it was a really cool XPATH example and just had to write about it.   &lt;/p&gt;
&lt;p&gt;To demonstrate the issue, the article I found this in, used a sample node set of: &lt;/p&gt;
&lt;pre&gt;&amp;lt;a&amp;gt;
    &amp;lt;b&amp;gt;zyx&amp;lt;/b&amp;gt;
    &amp;lt;b&amp;gt;wvu&amp;lt;/b&amp;gt;
    &amp;lt;b&amp;gt;tsr&amp;lt;/b&amp;gt;
    &amp;lt;b&amp;gt;qpo&amp;lt;/b&amp;gt;
&amp;lt;/a&amp;gt;

&lt;/pre&gt;&lt;p&gt;
And wanted to know the position of the &amp;lt;b&amp;gt; node that has the value of &#039;tsr&#039;.  &lt;/p&gt;
&lt;p&gt;The suggestion was an XPATH of:&lt;/p&gt;
&lt;pre&gt;count(a/b[.=&#039;tsr&#039;]/preceding-sibling::*)+1&lt;/pre&gt;&lt;p&gt;
This does not really help in an Identity Manager example, after all, what a/b in our context, so lets imagine a group membership node set, where we queried for Group membership and got back an &amp;lt;instance&amp;gt; document, that has a &amp;lt;attr&amp;gt; node, with an attribute of attr-name=&quot;Group Membership&quot; and a bunch of &amp;lt;value&amp;gt; nodes.&lt;/p&gt;
&lt;p&gt;So our node set looks something like:  (I grabbed this from an &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2632&quot;&gt;&lt;acronym title=&quot;An advanced, hierarchical directory service that is an integral part of the Microsoft Windows 2000 architecture. It is LDAP-compliant and built on the Internet.&quot;&gt;Active Directory&lt;/acronym&gt;&lt;/a&gt; driver example)&lt;/p&gt;
&lt;pre&gt;&amp;lt;nds dtdversion=&quot;2.2&quot;&amp;gt;
  &amp;lt;source&amp;gt;
    &amp;lt;product version=&quot;3.5.11.20080307 &quot;&amp;gt;DirXML&amp;lt;/product&amp;gt;
    &amp;lt;contact&amp;gt;Novell, Inc.&amp;lt;/contact&amp;gt;
  &amp;lt;/source&amp;gt;
  &amp;lt;output&amp;gt;
    &amp;lt;instance class-name=&quot;Group&quot; src-dn=&quot;CN=Domain Admins,CN=Users,DC=Test,DC=domain&quot;&amp;gt;
      &amp;lt;attr attr-name=&quot;Group Membership&quot;&amp;gt;
          &amp;lt;value type=&quot;dn&quot;&amp;gt;CN=Lateefah Smith,OU=Fac,OU=19TH,DC=Test,DC=domain&amp;lt;/value&amp;gt;
          &amp;lt;value type=&quot;dn&quot;&amp;gt;CN=Alonzo Duncan,OU=CustSvc,OU=NY,DC=Test,DC=domain&amp;lt;/value&amp;gt;
          &amp;lt;value type=&quot;dn&quot;&amp;gt;CN=Jeanie Jones,OU=CustSvc,OU=NY,DC=Test,DC=domain&amp;lt;/value&amp;gt;
          &amp;lt;value type=&quot;dn&quot;&amp;gt;CN=Armando Corona,OU=CustSvc,OU=NY,DC=Test,DC=domain&amp;lt;/value&amp;gt;
          &amp;lt;value type=&quot;dn&quot;&amp;gt;CN=idmUser,CN=Users,DC=Test,DC=domain&amp;lt;/value&amp;gt;
          &amp;lt;value type=&quot;dn&quot;&amp;gt;CN=Administrator,CN=Users,DC=Test,DC=domain&amp;lt;/value&amp;gt;
        &amp;lt;/add-value&amp;gt;
      &amp;lt;/modify-attr&amp;gt;
    &amp;lt;/modify&amp;gt;
  &amp;lt;/input&amp;gt;
&amp;lt;/nds&amp;gt;

&lt;/pre&gt;&lt;p&gt;
So what would XPATH be in our example? &lt;/p&gt;
&lt;pre&gt;count(attr/value[.=&#039;$TARGET&#039;]/preceding-sibling::*)+1&lt;/pre&gt;&lt;p&gt;
(I used a variable $TARGET instead of a literal string, since I think it is a bit clearer, but you could use a literal string like this instead &#039;CN=idmUser,CN=Users,DC=Test,DC=domain&#039; to specify the value). &lt;/p&gt;
&lt;p&gt;The way this works is it selects the node where the value equals the string we are looking for, then goes back one node, counts the number of nodes till there, and adds one to it.  (I think they used preceding-sibling plus one, because it is a built in test that lets you go back one, thus the need to add one.  &lt;/p&gt;
&lt;p&gt;Neat eh?  The best use I can think of this, is really the only time I needed to really use the [x] (you know, like [0] or [2] for the zeroth or second position)  notation to pick a node.  I was writing direct SQL commands in the JDBC driver, like in this article: &lt;a target=&quot;_blank&quot; href=&quot;http://www.novell.com/communities/node/2569/using-jdbc-driver-and-direct-sql&quot;&gt;Using the JDBC Driver and Direct SQL&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In that case I needed to send several SQL statements in one operation, (in the end I went back and did it all in one SQL statement once I got better at SQL, but on my first attempt I needed to do several SQL statements) and each SQL statement you want to send needs an XML node of &amp;lt;jdbc:sql&amp;gt; under a &amp;lt;jdbc:statement&amp;gt; node with the SQL statement.  In which case, you want to be sure you insert it into a specific node.  In that case, the ordering did matter, but I  concede it is a bit of a stretch.  But come on, it is a really neat XPATH example!&lt;/p&gt;
 &lt;div class=&quot;og_rss_groups&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;first last og_links&quot;&gt;&lt;a href=&quot;/communities/coolsolutions&quot; class=&quot;og_links&quot;&gt;Cool Solutions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description>
 <comments>http://www.novell.com/communities/node/6276/using-xpath-get-position-node-node-set#comments</comments>
 <category domain="http://www.novell.com/communities/taxonomy/term/6">DirXML</category>
 <category domain="http://www.novell.com/communities/coolsolutions/edirectory">eDirectory</category>
 <category domain="http://www.novell.com/communities/coolsolutions/nim">Identity Manager</category>
 <category domain="http://www.novell.com/communities/product/identitymanager/identitymanager35">Identity Manager 3.5</category>
 <category domain="http://www.novell.com/communities/topic/xpath">XPATH</category>
 <group domain="http://www.novell.com/communities/coolsolutions/ism" xmlns="http://drupal.org/project/og">Identity &amp;amp; Security Management Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions" xmlns="http://drupal.org/project/og">Cool Solutions</group>
 <pubDate>Sun, 08 Nov 2009 09:38:53 -0700</pubDate>
 <dc:creator>geoffc</dc:creator>
 <guid isPermaLink="false">6276 at http://www.novell.com/communities</guid>
</item>
<item>
 <title>Using DNS Aliases with SPNEGO</title>
 <link>http://www.novell.com/communities/node/9220/using-dns-aliases-spnego</link>
 <description> &lt;p&gt;One of the great features of Novell Access Manager is the integrated single sign-on capability from &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2930&quot;&gt;&lt;acronym title=&quot;An advanced, hierarchical directory service that is an integral part of the Microsoft Windows 2000 architecture. It is LDAP-compliant and built on the Internet&quot;&gt;Microsoft Active Directory&lt;/acronym&gt;&lt;/a&gt; (AD) domain member workstations.  Through the use of Kerberos and the Simple and Protected GSS-&lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2636&quot;&gt;&lt;acronym title=&quot;application programming interfaceA set of functions, procedures, values, or other defined interface standards that an application uses to request and carry out services performed by another program or by an operating system. A single API typically specifies how input should be requested and obtained, and how output should be done.&quot;&gt;API&lt;/acronym&gt;&lt;/a&gt; Negotiation Mechanism (SPNEGO), the Access Manager Identity Server (IdS) can seamlessly authenticate a Windows desktop.  &lt;/p&gt;
&lt;p&gt;Users logon to the desktop using their normal credentials and then when they attempt to access an Access Manager protected site, they are not required to login again.  Instead, a token is passed to the Access Manager IdS from the workstation.  The IdS then verifies that token and allows the user access per the policies as defined in Access Manager.  &lt;/p&gt;
&lt;p&gt;Complete details on configuring Access Manager can be found in the product documentation.   This basically works by the client requesting a service ticket from the domain controller for the IdS.  The actual name it passes to the domain controller is known as the Service Principal Name (SPN).  &lt;/p&gt;
&lt;p&gt;The SPN is made up of three components, the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/785&quot;&gt;&lt;acronym title=&quot;1. Short for protocol stack.2. A uniform set of rules or an agreed-upon method of communication that enable two devices to connect and transmit data or to send particular types of information between computer systems. Protocols determine how data is transmitted between computing devices and over networks. AFP, ALAP, RTMP, NCP, and IPX are examples of network protocols. AFP, ALAP, RTMP, NCP, and IPX are examples of network protocols. TCP/IP (Transfer Control Protocol/Internet Protocol), HTTP (Hypertext Transfer Protocol), and FTP (File Transfer Protocol) are examples of Internet protocols.&quot;&gt;protocol&lt;/acronym&gt;&lt;/a&gt;, the fully qualified domain name of the IdS and the client’s own AD domain name (known as the realm).  So, for example, lets say that the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1292&quot;&gt;&lt;acronym title=&quot;1. DaVinci Names Service: A DaVinci product that provides email directory services.2. distributed name services3. Domain Name System: A distributed database system that converts name-based addresses to TCP/IP addresses and vice versa for computers on a network or on the Internet.&quot;&gt;DNS&lt;/acronym&gt;&lt;/a&gt; name of our IdS (the Base &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2554&quot;&gt;&lt;acronym title=&quot;Uniform Resource LocatorThe addressing system used in the World Wide Web and other Internet resources. The URL contains information about the method of access (http://, for example), the name of the host and domain (such as www.suse.de) to be accessed, and the path of any file or document (such as /company/index.html) to be accessed. The complete URL of this example is http://www.suse.de/company/index.html.&quot;&gt;URL&lt;/acronym&gt;&lt;/a&gt;) is ids1.appdomain.com and our AD domain (the realm) is ad.appdomain.com.  This would make our SPN, as sent by the workstation, the following:&lt;/p&gt;
&lt;pre&gt;HTTP/ids1.appdomain.com@AD.APPDOMAIN.COM

&lt;/pre&gt;&lt;p&gt;This is what would be sent to the domain controller (the protocol is always listed as HTTP even if it is &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2856&quot;&gt;&lt;acronym title=&quot;Hypertext Transfer Protocol over Secure Socket Layer (SSL).A Web protocol that encrypts and decrypts user page requests as well as the pages that are returned by the Web server. HTTPS uses port 443 instead of HTTP port 80 in its interactions with TCP/IP.&quot;&gt;HTTPS&lt;/acronym&gt;&lt;/a&gt;).  The client gets back a token that has information about the user in a service ticket encrypted within the token.  This is passed in the header to the IdS where it is decrypted (using the shared secret in the nidpkey.keytab file).  At this point the user is authenticated and Access Manager will grant or deny access as appropriate.&lt;/p&gt;
&lt;p&gt;This all works fine as long as the fully qualified domain name used to build the SPN matches the actual DNS host record (A record) returned when the Windows desktop does a DNS query for ids1.appdomain.com.  But what happens if a DNS alias record (CNAME record) is used?  Lets say now that the actual &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/1472&quot;&gt;&lt;acronym title=&quot;1. In a network or distributed processing environment, the name used to identify the computer that provides services to other computers or terminals that can access the network.2. In the Domain Name System (DNS), a unique name associated with an IP address. A hostname cannot contain a space, tab, number sign (#), or end-of-line character.&quot;&gt;hostname&lt;/acronym&gt;&lt;/a&gt; of the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2314&quot;&gt;&lt;acronym title=&quot;A powerful computer running software that supplies network clients with services, such as file, print, communication, or application services. Examples of servers include1. Routing servers, which connect nodes and networks of similar architectures2. Gateway servers, which connect nodes and networks of different architectures by performing protocol conversions3. Terminal servers, print servers, disk servers, and file servers, which provide an interface between compatible peripheral devices on a local area network&quot;&gt;server&lt;/acronym&gt;&lt;/a&gt; acting as the IdS is linux1.appdomain.com and that the DNS record for ids1.appdomain.com is actually a CNAME pointing at linux1.appdomain.com:&lt;/p&gt;
&lt;pre&gt;linux1.appdomain.com. 		IN A		10.1.1.1
ids1.appdomain.com.		IN CNAME	linux1.appdomain.com.

&lt;/pre&gt;&lt;p&gt;What happens in this scenario?  When the client builds the SPN, it will look up ids1.appdomain.com which results in the CNAME being returned.  It will then take the actual host record and use that to build the SPN, resulting in:&lt;/p&gt;
&lt;pre&gt;HTTP/&lt;strong&gt;linux1&lt;/strong&gt;.appdomain.com@AD.APPDOMAIN.COM

&lt;/pre&gt;&lt;p&gt;This will be sent to the domain controller and will obviously fail since the SPN is incorrect, resulting in the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/517&quot;&gt;&lt;acronym title=&quot;1. Software used to explore or navigate. For example, a Web browser (such as Firefox or Internet Explorer) allows a user to access pages on the World Wide Web; a NetWare Administrator browser window allows a user to access the eDirectory tree. Web browsers with a particular encryption capability called Secure Socket Layer (SSL) are sometimes called SSL browsers.2. In the Common Desktop Environment (CDE) Application Builder, a window that provides a symbolic, hierarchical view of a module in a user interface. The browser shows parent-child relationships and groups. It can also be used to find objects in complex modules and to edit a user interface.&quot;&gt;browser&lt;/acronym&gt;&lt;/a&gt; being presented with a basic authentication &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/549&quot;&gt;&lt;acronym title=&quot;A small temporary window which appears on the computer screen which requires you to perform an action or select an option, or that provides you with information. For example, dialog boxes ask you questions like, &quot;Do you want to save this document?&quot; or &quot;Are you sure that you want to exit this program?&quot;After the information has been provided, the user can close the box by clicking &#039;okay,&#039; &#039;cancel,&#039; &#039;yes,&#039; or &#039;no.&#039;&quot;&gt;dialog box&lt;/acronym&gt;&lt;/a&gt; (the IdS falls back to NTLM authentication).  &lt;/p&gt;
&lt;p&gt;The preferred solution to this problem is to put in a second host entry for the IdS, not a CNAME:&lt;/p&gt;
&lt;pre&gt;linux1.appdomain.com. 		IN A		10.1.1.1
ids1.appdomain.com.		IN A		10.1.1.1&lt;/pre&gt;&lt;p&gt;This would result in a host record being returned to the client when it looks up ids1.appdomain.com and that is the value that would be used to build the SPN.  However, there are situations where it may not be possible to enter another host record in DNS.  For example, some fault tolerant layer-4 switching solutions provide for management of DNS entries as well in order to support disaster recovery scenarios (such as F5 Networks’ Global Traffic Manager).  In this case, the switch may be managing and changing the DNS entries for the virtual IP addresses.  Some organizations might use a dedicated or unique zone name for this and therefore have all application names referencing the switch managed entries thorough DNS aliases.  In this case, a CNAME must be used.&lt;/p&gt;
&lt;p&gt;This will work with Access Manager as long as the true, resolvable, host entry is used for the SPN.  So in this example, if a CNAME is used for ids1, the value of linux1.appdomain.com would need to be used for the user ID in AD, in the Kerberos class properties (see figure 1), and in the bcsLogin.conf on the IdS server as shown below:&lt;/p&gt;
&lt;pre&gt;
com.sun.security.jgss.accept {
com.sun.security.auth.module.Krb5LoginModule required
debug=&quot;true&quot;
useTicketCache=&quot;true&quot;
ticketCache=&quot;/opt/novell/java/jre/lib/security/spnegoTicket.cache&quot;
doNotPrompt=&quot;true&quot;
&lt;strong&gt;principal=&quot;HTTP/linux1.appdomain.com@AD.APPDOMAIN.COM&quot;&lt;/strong&gt;
useKeyTab=&quot;true&quot;
keyTab=&quot;/opt/novell/java/jre/lib/security/nidpkey.keytab&quot;
storeKey=&quot;true&quot;;
};

&lt;/pre&gt;&lt;div class=&quot;clear-block&quot;&gt;
&lt;div class=&quot;thumbnail&quot;&gt;
&lt;a href=&quot;http://www.novell.com/communities/files/u5193/AM_Kerberos_Class_Config.png&quot;&gt;&lt;img src=&quot;http://www.novell.com/communities/files/u5193/AM_Kerberos_Class_Config_0.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Figure 1: Kerberos Class Properties&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.novell.com/communities/files/u5193/AM_Kerberos_Class_Config.png&quot;&gt;Click to view&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;However, the URL listed in the local trusted site list in the browser must still be the actual IdS base URL (ids1.appdomain.com in this example), not the true hostname as referenced in the A record.&lt;/p&gt;
&lt;p&gt;Using the Kerberos feature in Access Manager is a great way to provide seamless single sign-on to Windows desktops.  But it is important to understand how the client is resolving the IdS and building the SPN in order to ensure it functions reliably.&lt;/p&gt;
 &lt;div class=&quot;og_rss_groups&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;first last og_links&quot;&gt;&lt;a href=&quot;/communities/coolsolutions&quot; class=&quot;og_links&quot;&gt;Cool Solutions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description>
 <comments>http://www.novell.com/communities/node/9220/using-dns-aliases-spnego#comments</comments>
 <category domain="http://www.novell.com/communities/product/access+manager">Access Manager</category>
 <category domain="http://www.novell.com/communities/content-type/tip">Tip</category>
 <category domain="http://www.novell.com/communities/topic/kerberos">Kerberos</category>
 <group domain="http://www.novell.com/communities/coolsolutions/ism" xmlns="http://drupal.org/project/og">Identity &amp;amp; Security Management Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions" xmlns="http://drupal.org/project/og">Cool Solutions</group>
 <pubDate>Fri, 06 Nov 2009 16:46:56 -0700</pubDate>
 <dc:creator>matt</dc:creator>
 <guid isPermaLink="false">9220 at http://www.novell.com/communities</guid>
</item>
<item>
 <title>DBCOPY Cleanup Tool</title>
 <link>http://www.novell.com/communities/node/9218/dbcopy-cleanup-tool</link>
 <description> &lt;p&gt;BACKGROUND:&lt;br /&gt;
We use DBCOPY to stage our GroupWise backups to a different location on the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2314&quot;&gt;&lt;acronym title=&quot;A powerful computer running software that supplies network clients with services, such as file, print, communication, or application services. Examples of servers include1. Routing servers, which connect nodes and networks of similar architectures2. Gateway servers, which connect nodes and networks of different architectures by performing protocol conversions3. Terminal servers, print servers, disk servers, and file servers, which provide an interface between compatible peripheral devices on a local area network&quot;&gt;server&lt;/acronym&gt;&lt;/a&gt;.  This function works just fine in the background.  The problem is that the files from the target server are not deleted if they no longer exist in the &lt;a class=&quot;glossary-term&quot; href=&quot;/communities/glossary/term/2362&quot;&gt;&lt;acronym title=&quot;The server from which data files, bindery files, and other information are migrated to a NetWare destination server during upgrade.&quot;&gt;source server&lt;/acronym&gt;&lt;/a&gt;.  So they will just stay there over time.  Until now.&lt;/p&gt;
&lt;p&gt;Using a tool called AutoDelete from Cyber-D, you can now schedule the older files to be purged from your staging area.  Simply download this free utility at &lt;a href=&quot;http://cyber-d.blogspot.com/2005/10/cyber-ds-auto-delete-101.html&quot; title=&quot;http://cyber-d.blogspot.com/2005/10/cyber-ds-auto-delete-101.html&quot;&gt;http://cyber-d.blogspot.com/2005/10/cyber-ds-auto-...&lt;/a&gt; (yup, free).  Configure the paths for the folder structure that you want pruned, set the period of time that you want to search for (since we perform daily DBCOPYs, there&#039;s no need to keep anything older than 2 days).  &lt;/p&gt;
&lt;p&gt;Our DBCOPY kicks off at 8pm and our AutoDelete will kick off daily at 2am, pruning anything older than two days. DBCOPY runs from our NetWare servers, but I am setting up AutoDelete on one of our GroupWise servers running on Windows to prune all of the other NetWare servers.&lt;/p&gt;
&lt;p&gt;WARNING:&lt;br /&gt;
If we request a restore to the DBCOPY area from tape, the Cyber-D AutoDelete tool will wipe that area clean of old files, so our restores need to be finished before the 8pm DBCOPY and the 2AM AutoDelete.&lt;/p&gt;
&lt;p&gt;I initially found this tool to remove files in a folder that were older than 30 days and it has done a great job in doing so.  I then used it on a folder that normally gets files deleted after 30 days, but I was finding that it needed to be cleaned out more frequently.  Since I could not alter the purging period of the existing tool, AutoDelete came in really handy.&lt;/p&gt;
&lt;p&gt;You&#039;ll find other uses for this tool in no time!&lt;/p&gt;
&lt;p&gt;This is Freeware, please consider donating (I have no affiliation with this product or company).  I believing in supporting companies who produce tools that work.&lt;/p&gt;
 &lt;div class=&quot;og_rss_groups&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;first last og_links&quot;&gt;&lt;a href=&quot;/communities/coolsolutions&quot; class=&quot;og_links&quot;&gt;Cool Solutions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description>
 <comments>http://www.novell.com/communities/node/9218/dbcopy-cleanup-tool#comments</comments>
 <category domain="http://www.novell.com/communities/taxonomy/term/1">GroupWise</category>
 <category domain="http://www.novell.com/communities/content-type/tip">Tip</category>
 <category domain="http://www.novell.com/communities/topic/3rd+party+products">3rd Party Products</category>
 <group domain="http://www.novell.com/communities/coolsolutions/workgroup" xmlns="http://drupal.org/project/og">Workgroup Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions/gwmag" xmlns="http://drupal.org/project/og">GroupWise Cool Solutions</group>
 <group domain="http://www.novell.com/communities/coolsolutions" xmlns="http://drupal.org/project/og">Cool Solutions</group>
 <pubDate>Fri, 06 Nov 2009 16:30:28 -0700</pubDate>
 <dc:creator>soundsolutionsinc</dc:creator>
 <guid isPermaLink="false">9218 at http://www.novell.com/communities</guid>
</item>
</channel>
</rss>
