skaiba1

Ensign
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-12-02
06:35
486 views
Hello Expert
I want to set my CN using username from email address
example
i have email address 'jhon.doe' @sample.mail and I want to set my cn become jhon.doe
how to do that
thanks for help
Cheers
1 Solution
Accepted Solutions


Knowledge Partner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-12-03
03:59
Norbert's version:
<do-set-local-variable name="lvSMTP" scope="policy">
<arg-string>
<token-text xml:space="preserve">jhon.doe@sample.mail</token-text>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="lvCN" scope="policy">
<arg-string>
<token-replace-first regex="@.*" replace-with="">
<token-local-variable name="lvSMTP"/>
</token-replace-first>
</arg-string>
</do-set-local-variable>
Simulation:
test : Applying rule 'lvSMTP'.
test : Action: do-set-local-variable("lvSMTP",scope="policy","jhon.doe@sample.mail").
test : arg-string("jhon.doe@sample.mail")
test : token-text("jhon.doe@sample.mail")
test : Arg Value: "jhon.doe@sample.mail".
test : Action: do-set-local-variable("lvCN",scope="policy",token-replace-first("@.*","",token-local-variable("lvSMTP"))).
test : arg-string(token-replace-first("@.*","",token-local-variable("lvSMTP")))
test : token-replace-first("@.*","",token-local-variable("lvSMTP"))
test : token-replace-first("@.*","",token-local-variable("lvSMTP"))
test : token-local-variable("lvSMTP")
test : Token Value: "jhon.doe@sample.mail".
test : Arg Value: "jhon.doe@sample.mail".
test : Token Value: "jhon.doe".
test : Arg Value: "jhon.doe".
<do-set-local-variable name="lvSMTP" scope="policy">
<arg-string>
<token-text xml:space="preserve">jhon.doe@sample.mail</token-text>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="lvCN" scope="policy">
<arg-string>
<token-replace-first regex="@.*" replace-with="">
<token-local-variable name="lvSMTP"/>
</token-replace-first>
</arg-string>
</do-set-local-variable>
Simulation:
test : Applying rule 'lvSMTP'.
test : Action: do-set-local-variable("lvSMTP",scope="policy","jhon.doe@sample.mail").
test : arg-string("jhon.doe@sample.mail")
test : token-text("jhon.doe@sample.mail")
test : Arg Value: "jhon.doe@sample.mail".
test : Action: do-set-local-variable("lvCN",scope="policy",token-replace-first("@.*","",token-local-variable("lvSMTP"))).
test : arg-string(token-replace-first("@.*","",token-local-variable("lvSMTP")))
test : token-replace-first("@.*","",token-local-variable("lvSMTP"))
test : token-replace-first("@.*","",token-local-variable("lvSMTP"))
test : token-local-variable("lvSMTP")
test : Token Value: "jhon.doe@sample.mail".
test : Arg Value: "jhon.doe@sample.mail".
test : Token Value: "jhon.doe".
test : Arg Value: "jhon.doe".
5 Replies
klasen

Micro Focus Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-12-02
07:44
You can do a replace-first with a regex like
@.*
https://regex101.com/ is a great site for testing your patterns.
--
Norbert
Norbert
skaiba1

Ensign
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-12-03
03:20
Hi @klasen
Would you advice me how to achieve that, and which policy configuration should i configure
Thanks


Knowledge Partner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-12-03
03:59
Norbert's version:
<do-set-local-variable name="lvSMTP" scope="policy">
<arg-string>
<token-text xml:space="preserve">jhon.doe@sample.mail</token-text>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="lvCN" scope="policy">
<arg-string>
<token-replace-first regex="@.*" replace-with="">
<token-local-variable name="lvSMTP"/>
</token-replace-first>
</arg-string>
</do-set-local-variable>
Simulation:
test : Applying rule 'lvSMTP'.
test : Action: do-set-local-variable("lvSMTP",scope="policy","jhon.doe@sample.mail").
test : arg-string("jhon.doe@sample.mail")
test : token-text("jhon.doe@sample.mail")
test : Arg Value: "jhon.doe@sample.mail".
test : Action: do-set-local-variable("lvCN",scope="policy",token-replace-first("@.*","",token-local-variable("lvSMTP"))).
test : arg-string(token-replace-first("@.*","",token-local-variable("lvSMTP")))
test : token-replace-first("@.*","",token-local-variable("lvSMTP"))
test : token-replace-first("@.*","",token-local-variable("lvSMTP"))
test : token-local-variable("lvSMTP")
test : Token Value: "jhon.doe@sample.mail".
test : Arg Value: "jhon.doe@sample.mail".
test : Token Value: "jhon.doe".
test : Arg Value: "jhon.doe".
<do-set-local-variable name="lvSMTP" scope="policy">
<arg-string>
<token-text xml:space="preserve">jhon.doe@sample.mail</token-text>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="lvCN" scope="policy">
<arg-string>
<token-replace-first regex="@.*" replace-with="">
<token-local-variable name="lvSMTP"/>
</token-replace-first>
</arg-string>
</do-set-local-variable>
Simulation:
test : Applying rule 'lvSMTP'.
test : Action: do-set-local-variable("lvSMTP",scope="policy","jhon.doe@sample.mail").
test : arg-string("jhon.doe@sample.mail")
test : token-text("jhon.doe@sample.mail")
test : Arg Value: "jhon.doe@sample.mail".
test : Action: do-set-local-variable("lvCN",scope="policy",token-replace-first("@.*","",token-local-variable("lvSMTP"))).
test : arg-string(token-replace-first("@.*","",token-local-variable("lvSMTP")))
test : token-replace-first("@.*","",token-local-variable("lvSMTP"))
test : token-replace-first("@.*","",token-local-variable("lvSMTP"))
test : token-local-variable("lvSMTP")
test : Token Value: "jhon.doe@sample.mail".
test : Arg Value: "jhon.doe@sample.mail".
test : Token Value: "jhon.doe".
test : Arg Value: "jhon.doe".


Knowledge Partner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-12-03
04:08
Another simple option: use built-in XPATH function substring-before.
<do-set-local-variable name="lvCN" scope="policy">
<arg-string>
<token-xpath expression="substring-before($lvSMTP,'@')"/>
</arg-string>
</do-set-local-variable>
Simulation:
test : Applying rule 'lvSMTP'.
test : Action: do-set-local-variable("lvSMTP",scope="policy","jhon.doe@sample.mail").
test : arg-string("jhon.doe@sample.mail")
test : token-text("jhon.doe@sample.mail")
test : Arg Value: "jhon.doe@sample.mail".
test : Action: do-set-local-variable("lvCN",scope="policy",token-xpath("substring-before($lvSMTP,'@')")).
test : arg-string(token-xpath("substring-before($lvSMTP,'@')"))
test : token-xpath("substring-before($lvSMTP,'@')")
test : Token Value: "jhon.doe".
test : Arg Value: "jhon.doe".
and many other options available.
🙂
<do-set-local-variable name="lvCN" scope="policy">
<arg-string>
<token-xpath expression="substring-before($lvSMTP,'@')"/>
</arg-string>
</do-set-local-variable>
Simulation:
test : Applying rule 'lvSMTP'.
test : Action: do-set-local-variable("lvSMTP",scope="policy","jhon.doe@sample.mail").
test : arg-string("jhon.doe@sample.mail")
test : token-text("jhon.doe@sample.mail")
test : Arg Value: "jhon.doe@sample.mail".
test : Action: do-set-local-variable("lvCN",scope="policy",token-xpath("substring-before($lvSMTP,'@')")).
test : arg-string(token-xpath("substring-before($lvSMTP,'@')"))
test : token-xpath("substring-before($lvSMTP,'@')")
test : Token Value: "jhon.doe".
test : Arg Value: "jhon.doe".
and many other options available.
🙂
skaiba1

Ensign
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-12-03
04:35
Thanks @al_b
that help me alot 😁