Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Jevans78 Absent Member.
Absent Member.
582 views

Regex to search for Primary ProxyAddress AD driver


Hi,

I'm quite new to Regex, but have been testing and reading many online
articles that all seem to say the same thing, but it is not working for
me.

I'm writing a rule to sync the InternetEMailAddress to ProxyAddresses in
AD.

In doing so it is important that only the Primary SMTP: address is
updated.

I have written a rule that outputs the ProxyAddresses to a NodeSet, and
then each node is checked to see if it is the primary - i.e. with the
capitals SMTP:

The rule below is evaluating to True for every smtp: address listed and
not just the SMTP: primary. I tried without the (?c) and get the same
result, so I must be missing something:

<arg-actions>
<do-if>
<arg-conditions>
<and>
*<if-local-variable mode="regex" name="current-node"
op="equal">^(?c)SMTP:.*</if-local-variable>*
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="lvPrimaryAddressToUpdate">
<arg-string>
<token-local-variable name="current-node"/>
</arg-string>
</do-set-local-variable>
<do-remove-dest-attr-value direct="true" name="ProxyAddresses">
<arg-value type="string">
<token-local-variable name="lvPrimaryAddressToUpdate"/>
</arg-value>
</do-remove-dest-attr-value>
<do-add-dest-attr-value direct="true" name="ProxyAddresses">
<arg-value type="string">
<token-text xml:space="preserve">SMTP:</token-text>
<token-op-attr name="Internet EMail Address"/>
</arg-value>
</do-add-dest-attr-value>
</arg-actions>

Is anyone able to help at all?

Thanks in advance


--
Jevans78
------------------------------------------------------------------------
Jevans78's Profile: https://forums.netiq.com/member.php?userid=7684
View this thread: https://forums.netiq.com/showthread.php?t=53965

Labels (1)
0 Likes
9 Replies
Jevans78 Absent Member.
Absent Member.

Re: Regex to search for Primary ProxyAddress AD driver


level 3 trace of the rule running is below:

[08/04/15 12:31:39.058]:Active Directory ST: Query from
policy result
[08/04/15 12:31:39.059]:Active Directory ST:
<nds dtdversion="1.1" ndsversion="8.7">
<source>
<product asn1id="" build="20120330_120000"
instance="\LABVAULT\system\Driverset1\Driverset1\Active Directory"
version="4.0.0.0">AD</product>
<contact>Novell, Inc.</contact>
</source>
<output>
<instance class-name="User" event-id="0" src-dn="CN=smtp
smtp,OU=Users,OU=Accounts,DC=AD2,DC=com">
<association>1271ca76911ab74097c8bec213b7c037</association>
<attr attr-name="proxyAddresses">
<value naming="true"
type="string">smtp:Johnny@TAWE.Mail.ac.uk</value>
<value naming="true"
type="string">smtp:JunkMailbox@TAWE.Mail.ac.uk</value>
<value naming="true"
type="string">SMTP:JohnsNewEmail44@Mail.ac.uk</value>
<value naming="true"
type="string">irl:x500.ldjdd.odjdud</value>
</attr>
</instance>
<status event-id="0" level="success"/>
</output>
</nds>
[08/04/15 12:31:39.061]:Active Directory ST: Token Value:
{<value> @naming = "true" @type = "string",<value> @naming = "true"
@type = "string",<valu
e> @naming = "true" @type = "string",<value> @naming = "true" @type =
"string"}.
[08/04/15 12:31:39.061]:Active Directory ST: Arg Value:
{<value> @naming = "true" @type = "string",<value> @naming = "true"
@type = "string",<value>
@naming = "true" @type = "string",<value> @naming = "true" @type =
"string"}.
[08/04/15 12:31:39.061]:Active Directory ST: Action:
do-for-each(arg-node-set(token-local-variable("lvProxyAddresses"))).
[08/04/15 12:31:39.062]:Active Directory ST:
arg-node-set(token-local-variable("lvProxyAddresses"))
[08/04/15 12:31:39.062]:Active Directory ST:
token-local-variable("lvProxyAddresses")
[08/04/15 12:31:39.062]:Active Directory ST: Token Value:
{<value> @naming = "true" @type = "string",<value> @naming = "true"
@type = "string",<valu
e> @naming = "true" @type = "string",<value> @naming = "true" @type =
"string"}.
[08/04/15 12:31:39.063]:Active Directory ST: Arg Value:
{<value> @naming = "true" @type = "string",<value> @naming = "true"
@type = "string",<value>
@naming = "true" @type = "string",<value> @naming = "true" @type =
"string"}.
[08/04/15 12:31:39.063]:Active Directory ST: Performing actions
for local-variable(current-node) = <value> @naming = "true" @type =
"string".
[08/04/15 12:31:39.063]:Active Directory ST: Action: do-if().
[08/04/15 12:31:39.064]:Active Directory ST: Evaluating
conditions.
[08/04/15 12:31:39.064]:Active Directory ST:
(if-local-variable 'current-node' match "^(?c)SMTP:.*") = TRUE.
[08/04/15 12:31:39.064]:Active Directory ST: Performing if
actions.
[08/04/15 12:31:39.064]:Active Directory ST: Action:
do-set-local-variable("lvPrimaryAddressToUpdate",token-local-variable("current-node")).
[08/04/15 12:31:39.065]:Active Directory ST:
arg-string(token-local-variable("current-node"))
[08/04/15 12:31:39.065]:Active Directory ST:
token-local-variable("current-node")
[08/04/15 12:31:39.065]:Active Directory ST: Token
Value: "smtp:Johnny@TAWE.Mail.ac.uk".
[08/04/15 12:31:39.065]:Active Directory ST: Arg Value:
"smtp:Johnny@TAWE.Mail.ac.uk".
[08/04/15 12:31:39.065]:Active Directory ST: Action:
do-remove-dest-attr-value("ProxyAddresses",direct="true",token-local-variable("lvPrimaryAdd
ressToUpdate")).
[08/04/15 12:31:39.066]:Active Directory ST:
arg-string(token-local-variable("lvPrimaryAddressToUpdate"))
[08/04/15 12:31:39.066]:Active Directory ST:
token-local-variable("lvPrimaryAddressToUpdate")
[08/04/15 12:31:39.066]:Active Directory ST: Token
Value: "smtp:Johnny@TAWE.Mail.ac.uk".
[08/04/15 12:31:39.067]:Active Directory ST: Arg Value:
"smtp:Johnny@TAWE.Mail.ac.uk".
[08/04/15 12:31:39.067]:Active Directory ST: Action:
do-add-dest-attr-value("ProxyAddresses",direct="true","SMTP:"+token-op-attr("Internet
EMail
Address")).
[08/04/15 12:31:39.067]:Active Directory ST:
arg-string("SMTP:"+token-op-attr("Internet EMail Address"))
[08/04/15 12:31:39.067]:Active Directory ST:
token-text("SMTP:")
[08/04/15 12:31:39.068]:Active Directory ST:
token-op-attr("Internet EMail Address")
[08/04/15 12:31:39.068]:Active Directory ST: Token
Value: "JohnsNewEmail44567@Mail.ac.uk".
[08/04/15 12:31:39.068]:Active Directory ST: Arg Value:
"SMTP:JohnsNewEmail44567@Mail.ac.uk".

As you can see, the first node is smtp: whereas the Regex evaluates to
True for this. The only address that evaluates to false is the irl:x500
address.


--
Jevans78
------------------------------------------------------------------------
Jevans78's Profile: https://forums.netiq.com/member.php?userid=7684
View this thread: https://forums.netiq.com/showthread.php?t=53965

0 Likes
Knowledge Partner
Knowledge Partner

Re: Regex to search for Primary ProxyAddress AD driver

how about if XPATH true "starts-with($current-node,"SMTP:")

That is a case sensitive compare.



> I'm quite new to Regex, but have been testing and reading many online
> articles that all seem to say the same thing, but it is not working for
> me.
>
> I'm writing a rule to sync the InternetEMailAddress to ProxyAddresses in
> AD.
>
> In doing so it is important that only the Primary SMTP: address is
> updated.
>
> I have written a rule that outputs the ProxyAddresses to a NodeSet, and
> then each node is checked to see if it is the primary - i.e. with the
> capitals SMTP:
>
> The rule below is evaluating to True for every smtp: address listed and
> not just the SMTP: primary. I tried without the (?c) and get the same
> result, so I must be missing something:
>
> <arg-actions>
> <do-if>
> <arg-conditions>
> <and>
> *<if-local-variable mode="regex" name="current-node"
> op="equal">^(?c)SMTP:.*</if-local-variable>*
> </and>
> </arg-conditions>
> <arg-actions>
> <do-set-local-variable name="lvPrimaryAddressToUpdate">
> <arg-string>
> <token-local-variable name="current-node"/>
> </arg-string>
> </do-set-local-variable>
> <do-remove-dest-attr-value direct="true" name="ProxyAddresses">
> <arg-value type="string">
> <token-local-variable name="lvPrimaryAddressToUpdate"/>
> </arg-value>
> </do-remove-dest-attr-value>
> <do-add-dest-attr-value direct="true" name="ProxyAddresses">
> <arg-value type="string">
> <token-text xml:space="preserve">SMTP:</token-text>
> <token-op-attr name="Internet EMail Address"/>
> </arg-value>
> </do-add-dest-attr-value>
> </arg-actions>
>
> Is anyone able to help at all?
>
> Thanks in advance
>
>


0 Likes
Jevans78 Absent Member.
Absent Member.

Re: Regex to search for Primary ProxyAddress AD driver


Thanks Geoff for the quick reply.

I will try this and let you know. As with all things IDM it seems there
are many ways to skin a cat.


--
Jevans78
------------------------------------------------------------------------
Jevans78's Profile: https://forums.netiq.com/member.php?userid=7684
View this thread: https://forums.netiq.com/showthread.php?t=53965

0 Likes
Knowledge Partner
Knowledge Partner

Re: Regex to search for Primary ProxyAddress AD driver

On 8/4/2015 8:24 AM, Jevans78 wrote:
>
> Thanks Geoff for the quick reply.
>
> I will try this and let you know. As with all things IDM it seems there
> are many ways to skin a cat.


The cat on the cover of my IDM tokens book would disagree with that, but
you know, that is a good byline to add to it... (I will have to think
about that for the next edition)

Also you could substring-after($current-node,"SMTP:") then test if regex
of .+ is true on the remainder.

Lots of options. Some sillier than others.
0 Likes
Jevans78 Absent Member.
Absent Member.

Re: Regex to search for Primary ProxyAddress AD driver


That worked like a charm. Thanks ever so much for pointing me in the
right direction.

Out of interest, is the Regex not capable of being case sensitive? From
reading online it should be by default, but that definitely was not the
case in testing.

Thanks again!


--
Jevans78
------------------------------------------------------------------------
Jevans78's Profile: https://forums.netiq.com/member.php?userid=7684
View this thread: https://forums.netiq.com/showthread.php?t=53965

0 Likes
Knowledge Partner
Knowledge Partner

Re: Regex to search for Primary ProxyAddress AD driver

On 8/4/2015 1:04 PM, Jevans78 wrote:
>
> That worked like a charm. Thanks ever so much for pointing me in the
> right direction.
>
> Out of interest, is the Regex not capable of being case sensitive? From
> reading online it should be by default, but that definitely was not the
> case in testing.


Aaron answered that. By default IDM's Regex is case insensitive, you
need the (?-i) I think to enable that.


0 Likes
Knowledge Partner
Knowledge Partner

Re: Regex to search for Primary ProxyAddress AD driver

On 08/04/2015 05:57 AM, Jevans78 wrote:
>
> I'm quite new to Regex, but have been testing and reading many online
> articles that all seem to say the same thing, but it is not working for
> me.
>
> I'm writing a rule to sync the InternetEMailAddress to ProxyAddresses in
> AD.


Ugh; welcome to the mis-handling of multi-valued attributes.

> I have written a rule that outputs the ProxyAddresses to a NodeSet, and
> then each node is checked to see if it is the primary - i.e. with the
> capitals SMTP:


And using a regex yo have problems, yes. IDM forces case-insensitive
comparisons by default, as you may have found.

> The rule below is evaluating to True for every smtp: address listed and
> not just the SMTP: primary. I tried without the (?c) and get the same
> result, so I must be missing something:


I'm not sure what (?c) is supposed to do, but to make something NOT
case-insensitive (i.e. case-sensitive) use (?-i). See Java documentation
9the Pattern or Matcher class.... I always forget which) for the original
reference.

--
Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below...
0 Likes
Knowledge Partner
Knowledge Partner

Re: Regex to search for Primary ProxyAddress AD driver

On 8/4/2015 8:52 AM, ab wrote:
> On 08/04/2015 05:57 AM, Jevans78 wrote:
>>
>> I'm quite new to Regex, but have been testing and reading many online
>> articles that all seem to say the same thing, but it is not working for
>> me.
>>
>> I'm writing a rule to sync the InternetEMailAddress to ProxyAddresses in
>> AD.

>
> Ugh; welcome to the mis-handling of multi-valued attributes.


It is AD's absence of structured attributes that caused this. Look at
the Email Address in eDir syntax for a more useful way to handle this.

Multi valued is not root cause of this problem, I think.


0 Likes
Knowledge Partner
Knowledge Partner

Re: Regex to search for Primary ProxyAddress AD driver


I copy in my answer from an old tread http://tinyurl.com/o9djgjd

> Thank you both,
>
> I was clearly mixing things up with trying to do a case sensitive
> regex.
> This is the working codepart:
> <if-local-variable mode="regex" name="current-node"
> op="equal">(?-i:SMTP):.*</if-local-variable>
>
> The key here is mode="regex" as Geoffrey pointed out and then the
> (?-i:SMTP) that is the switch to make it case sensitive ?-iu makes the
> same thing for unicode as Aaron found.
>
> 'Case-Insensitive Matching in Java RegEx : Xueming Shen's Blog'
> (http://blogs.sun.com/xuemingshen/ent...tching_in_java)
>
> While doing this I realized that a lot of testing engines don't accept
> this, they have a checkbox for it but don't accept the actual code.
> One thet worked is:
> 'RegEx: online regular expression testing'
> (http://www.regexplanet.com/simple/index.html)



--
joakim_ganse
------------------------------------------------------------------------
joakim_ganse's Profile: https://forums.netiq.com/member.php?userid=159
View this thread: https://forums.netiq.com/showthread.php?t=53965

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.