Multi Valued attribute returning values as single String.

Hello All,

I am using Loop Back driver to send email notification to users when the roles assigned to them are about to expire. In the email I need to Publish Role CN, Expiry date and nrfRoleCategorykey (multi-valued attribute in the role). For each role I am fetching nrfRoleCategorykey value using query, as it is multi-valued attribute it is giving all the values as a single concatenated string without any delimiter example as below:
nrfroleCategoryKey: AlphaBetaDelta……. etc.
I want these values with some delimiter as (Alpha, Beta, Delta,...etc).

Below is the code i am using:

<do-set-local-variable name="varRoleCatogeryKey" scope="policy">
<arg-node-set>
<token-query class-name="nrfRole" datastore="src">
<arg-dn>
<token-global-variable name="RolesContainer"/>
</arg-dn>
<arg-match-attr name="CN">
<arg-value type="string">
<token-local-variable name="RoleName"/>
</arg-value>
</arg-match-attr>
<arg-string>
<token-text xml:space="preserve">nrfRoleCategoryKey</token-text>
</arg-string>
</token-query>
</arg-node-set>
</do-set-local-variable>
<do-set-local-variable name="varMultipleRoleCatKeys" scope="policy">
<arg-string>
<token-text xml:space="preserve"/>
</arg-string>
</do-set-local-variable>
<do-for-each>
<arg-node-set>
<token-local-variable name="varRoleCatogeryKey"/>
</arg-node-set>
<arg-actions>
<do-set-local-variable name="varMultipleRoleCatKeys" scope="policy">
<arg-string>
<token-local-variable name="varMultipleRoleCatKeys"/>
<token-text xml:space="preserve">,</token-text>
<token-local-variable name="current-node"/>
</arg-string>
</do-set-local-variable>
</arg-actions>
</do-for-each>
=======================================================================================
Part of Trace:

[05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST: Action: do-set-local-variable("varMultipleRoleCatKeys",scope="policy",token-local-variable("varMultipleRoleCatKeys") "," token-local-variable("current-node")).
[05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST: arg-string(token-local-variable("varMultipleRoleCatKeys") "," token-local-variable("current-node"))
[05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST: token-local-variable("varMultipleRoleCatKeys")
[05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST: Token Value: "".
[05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST: token-text(",")
[05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST: token-local-variable("current-node")
[05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST: Token Value: "AlphaBetaDelta".
[05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST: Arg Value: ",AlphaBetaDelta".
==============================================

current Node is returning value as "AlphaBetaDelta" .

Some one help me on this how to achieve these values as Alpha,Beta,Delta.



Regards,
Eswar
Parents
  • On 6/1/2017 7:34 AM, ed00491298 wrote:
    >
    > Hello All,
    >
    > I am using Loop Back driver to send email notification to users when the
    > roles assigned to them are about to expire. In the email I need to
    > Publish Role CN, Expiry date and nrfRoleCategorykey (multi-valued
    > attribute in the role). For each role I am fetching nrfRoleCategorykey
    > value using query, as it is multi-valued attribute it is giving all the
    > values as a single concatenated string without any delimiter example as
    > below:
    > nrfroleCategoryKey: AlphaBetaDelta��. etc.
    > I want these values with some delimiter as (Alpha, Beta, Delta,...etc).
    >
    > BELOW IS THE CODE I AM USING:
    >
    > <do-set-local-variable name="varRoleCatogeryKey" scope="policy">
    > <arg-node-set>
    > <token-query class-name="nrfRole" datastore="src">
    > <arg-dn>
    > <token-global-variable name="RolesContainer"/>
    > </arg-dn>
    > <arg-match-attr name="CN">
    > <arg-value type="string">
    > <token-local-variable name="RoleName"/>
    > </arg-value>
    > </arg-match-attr>
    > <arg-string>
    > <token-text
    > xml:space="preserve">nrfRoleCategoryKey</token-text>
    > </arg-string>
    > </token-query>
    > </arg-node-set>
    > </do-set-local-variable>
    > <do-set-local-variable name="varMultipleRoleCatKeys"
    > scope="policy">
    > <arg-string>
    > <token-text xml:space="preserve"/>
    > </arg-string>
    > </do-set-local-variable>
    > <do-for-each>
    > <arg-node-set>
    > <token-local-variable name="varRoleCatogeryKey"/>
    > </arg-node-set>
    > <arg-actions>
    > <do-set-local-variable name="varMultipleRoleCatKeys"
    > scope="policy">
    > <arg-string>
    > <token-local-variable name="varMultipleRoleCatKeys"/>
    > <token-text xml:space="preserve">,</token-text>
    > <token-local-variable name="current-node"/>
    > </arg-string>
    > </do-set-local-variable>
    > </arg-actions>
    > </do-for-each>
    > =======================================================================================
    > PART OF TRACE:
    >
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > Action:
    > do-set-local-variable("varMultipleRoleCatKeys",scope="policy",token-local-variable("varMultipleRoleCatKeys") "," token-local-variable("current-node")).
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    >
    > arg-string(token-local-variable("varMultipleRoleCatKeys") "," token-local-variable("current-node"))
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > token-local-variable("varMultipleRoleCatKeys")
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > Token Value: "".
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > token-text(",")
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > token-local-variable("current-node")
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > Token Value: "AlphaBetaDelta".
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > Arg Value: ",AlphaBetaDelta".
    > ==============================================
    >
    > current Node is returning value as "AlphaBetaDelta" .
    >
    > Some one help me on this how to achieve these values as
    > Alpha,Beta,Delta.


    You are treating a nodeset as a string. in which case, the text()
    elements are concatted together as you see.

    Use the Join token on the Nodeset variable to make string of all the
    values.

    If you need something more complex, then loop over the nodeset and do
    what you need inside the loop.

    An XDS nodeset from a Query token, would look like:

    <instance src-dn="\T\o\ou\cn">
    <attr attr-name="attributeName">
    <value>SomeText</value>
    </attr>
    </instance>

    (Typed freehand as an example)

    So the SomeText is the only text() element in that nodeset example.

    If your nodeset had 2 attributes, you would get all the values
    concatted. So be careful what you ask for.


Reply
  • On 6/1/2017 7:34 AM, ed00491298 wrote:
    >
    > Hello All,
    >
    > I am using Loop Back driver to send email notification to users when the
    > roles assigned to them are about to expire. In the email I need to
    > Publish Role CN, Expiry date and nrfRoleCategorykey (multi-valued
    > attribute in the role). For each role I am fetching nrfRoleCategorykey
    > value using query, as it is multi-valued attribute it is giving all the
    > values as a single concatenated string without any delimiter example as
    > below:
    > nrfroleCategoryKey: AlphaBetaDelta��. etc.
    > I want these values with some delimiter as (Alpha, Beta, Delta,...etc).
    >
    > BELOW IS THE CODE I AM USING:
    >
    > <do-set-local-variable name="varRoleCatogeryKey" scope="policy">
    > <arg-node-set>
    > <token-query class-name="nrfRole" datastore="src">
    > <arg-dn>
    > <token-global-variable name="RolesContainer"/>
    > </arg-dn>
    > <arg-match-attr name="CN">
    > <arg-value type="string">
    > <token-local-variable name="RoleName"/>
    > </arg-value>
    > </arg-match-attr>
    > <arg-string>
    > <token-text
    > xml:space="preserve">nrfRoleCategoryKey</token-text>
    > </arg-string>
    > </token-query>
    > </arg-node-set>
    > </do-set-local-variable>
    > <do-set-local-variable name="varMultipleRoleCatKeys"
    > scope="policy">
    > <arg-string>
    > <token-text xml:space="preserve"/>
    > </arg-string>
    > </do-set-local-variable>
    > <do-for-each>
    > <arg-node-set>
    > <token-local-variable name="varRoleCatogeryKey"/>
    > </arg-node-set>
    > <arg-actions>
    > <do-set-local-variable name="varMultipleRoleCatKeys"
    > scope="policy">
    > <arg-string>
    > <token-local-variable name="varMultipleRoleCatKeys"/>
    > <token-text xml:space="preserve">,</token-text>
    > <token-local-variable name="current-node"/>
    > </arg-string>
    > </do-set-local-variable>
    > </arg-actions>
    > </do-for-each>
    > =======================================================================================
    > PART OF TRACE:
    >
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > Action:
    > do-set-local-variable("varMultipleRoleCatKeys",scope="policy",token-local-variable("varMultipleRoleCatKeys") "," token-local-variable("current-node")).
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    >
    > arg-string(token-local-variable("varMultipleRoleCatKeys") "," token-local-variable("current-node"))
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > token-local-variable("varMultipleRoleCatKeys")
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > Token Value: "".
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > token-text(",")
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > token-local-variable("current-node")
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > Token Value: "AlphaBetaDelta".
    > [05/31/17 11:35:23.732]:Loopback Driver Roles Exp Notification ST:
    > Arg Value: ",AlphaBetaDelta".
    > ==============================================
    >
    > current Node is returning value as "AlphaBetaDelta" .
    >
    > Some one help me on this how to achieve these values as
    > Alpha,Beta,Delta.


    You are treating a nodeset as a string. in which case, the text()
    elements are concatted together as you see.

    Use the Join token on the Nodeset variable to make string of all the
    values.

    If you need something more complex, then loop over the nodeset and do
    what you need inside the loop.

    An XDS nodeset from a Query token, would look like:

    <instance src-dn="\T\o\ou\cn">
    <attr attr-name="attributeName">
    <value>SomeText</value>
    </attr>
    </instance>

    (Typed freehand as an example)

    So the SomeText is the only text() element in that nodeset example.

    If your nodeset had 2 attributes, you would get all the values
    concatted. So be careful what you ask for.


Children
  • Geoffrey Carman wrote:

    > You are treating a nodeset as a string. in which case, the text() elements
    > are concatted together as you see.


    To add a little to the confusion, here's what the xpath 1.0 RFC has to say
    about nodeset to string conversion:

    "A node-set is converted to a string by returning the string-value of the node
    in the node-set that is first in document order."

    "The string-value of an element node is the concatenation of the string-values
    of all text node descendants of the element node in document order."

    " The string-value of a text node is the character data"

    -> https://www.w3.org/TR/xpath/

    varRoleCatogeryKey is set by token-query so it contains a single instance node,
    which results in a string value as shown in the trace. If the nrfRole object
    was associated, the association value would also been part of the string value,
    further messing things up.

    He should've looped over xpath($varRoleCatogeryKey//value) instead to achieve
    what he was trying to do. Better use token-join as already suggested in this
    use case, though.

    --
    http://www.is4it.de/en/solution/identity-access-management/

    (If you find this post helpful, please click on the star below.)