Regular Expression Extract Username from DN

  • 27 February 2017
  • 14 replies
  • 20 views

Badge +3

I'm trying to find the manager of a task assignee. When I use Query LDAP to find the manager, it returns the distinguished name of the manager. We need to forward the task to the assignee's manager once the assignee completes the task. I thought pulling the username from the LDAP return:

CN=<manager name> (<manager username>),OU=<OU>,OU=<OU>,OU=<OU>,DC=<DC>,DC=<DC>, would be the best way to go. I then could use that username to create a new task for the manager. I'm trying to get a grasp of regular expressions but it's been really confusing to me. Can someone assist in the right expression to use? Or if there's a better way to pull the manager of the task assignee that's just as good.

*Note: The user initiating the workflow is not the assignee.

Thanks!


14 replies

Userlevel 5
Badge +14

assuming angle brackets are not part of manager's name and round brackets enclose only manager's name, following regex should work for you

(?<=()[ws]+(?=))
Badge +3

That seemed to work, thanks for your quick response!

Beau Landry

Content Management Application Administrator

Continental Resources, Inc.

20 N. Broadway

OKC, OK 73102

P/F: 405.774.5963

C: 405.435.0584

Beau.landry@clr.com<mailto:Beau.landry@clr.com>

www.clr.com<http://www.clr.com/>

Mailing:

P.O. Box 269000

OKC, OK 73126

Badge +3

One other question, could you possibly break this expression down so I know why it worked?

Beau Landry

Content Management Application Administrator

Continental Resources, Inc.

20 N. Broadway

OKC, OK 73102

P/F: 405.774.5963

C: 405.435.0584

Beau.landry@clr.com<mailto:Beau.landry@clr.com>

www.clr.com<http://www.clr.com/>

Mailing:

P.O. Box 269000

OKC, OK 73126

Badge +3

So come to find out, not all of our accounts have the username in the DN. That is something new they just started adding in AD. Is there a different way to pull the task assignee’s manager username or email address so we can create a task for them as well? Thanks again.

Beau Landry

Content Management Application Administrator

Continental Resources, Inc.

20 N. Broadway

OKC, OK 73102

P/F: 405.774.5963

C: 405.435.0584

Beau.landry@clr.com<mailto:Beau.landry@clr.com>

www.clr.com<http://www.clr.com/>

Mailing:

P.O. Box 269000

OKC, OK 73126

Badge +7

Well, if your AD has the manager property correctly filled and UPS is setup you could use the query user profile action to query the UPS for a user's manager.

If you want the manager of the current person, there should already be a workflow context property for the manager.

Badge +3

Thanks for your response. I’m unable to use the manager context property because the person initiating the workflow is not the same person that’s getting assigned the task.

I meant to add we do not have the Enterprise edition, so we do not have the “query user profile” action available to us.

Beau Landry

Content Management Application Administrator

Continental Resources, Inc.

20 N. Broadway

OKC, OK 73102

P/F: 405.774.5963

C: 405.435.0584

Beau.landry@clr.com<mailto:Beau.landry@clr.com>

www.clr.com<http://www.clr.com/>

Mailing:

P.O. Box 269000

OKC, OK 73126

Userlevel 6
Badge +15

You may want to post a new question with this in it, as it's a bit different from the title on this one! You'll probably get more responses.

Badge +7

But do you have the manager property filled in AD?

Badge +3

I’m starting a new discussion on this now.

We do have the manager property populated. The problem is when I query LDAP in Nintex WF, it pulls the DN. I need to be able to pull the manager’s username or email in order to create a task for them after their direct report completes his/her task.

Beau Landry

Content Management Application Administrator

Continental Resources, Inc.

20 N. Broadway

OKC, OK 73102

P/F: 405.774.5963

C: 405.435.0584

Beau.landry@clr.com<mailto:Beau.landry@clr.com>

www.clr.com<http://www.clr.com/>

Mailing:

P.O. Box 269000

OKC, OK 73126

Badge +3

Here’s the new discussion link: https://community.nintex.com/message/56566-find-managers-usernameemail-address.

Beau Landry

Content Management Application Administrator

Continental Resources, Inc.

20 N. Broadway

OKC, OK 73102

P/F: 405.774.5963

C: 405.435.0584

Beau.landry@clr.com<mailto:Beau.landry@clr.com>

www.clr.com<http://www.clr.com/>

Mailing:

P.O. Box 269000

OKC, OK 73126

Badge +3

Here’s the new discussion link: https://community.nintex.com/message/56566-find-managers-usernameemail-address.

Beau Landry

Content Management Application Administrator

Continental Resources, Inc.

20 N. Broadway

OKC, OK 73102

P/F: 405.774.5963

C: 405.435.0584

Beau.landry@clr.com<mailto:Beau.landry@clr.com>

www.clr.com<http://www.clr.com/>

Mailing:

P.O. Box 269000

OKC, OK 73126

Userlevel 5
Badge +14

here you are

(?<=()   .........     searches for opening bracket right before pattern of interest, without including it into match

[ws]+  ............... searches for presence of 1 or more of any combination of alphanumeric character and white space character

(?=)) .................  searches for closing bracket right after pattern of interest, without including it into match

Badge +3

Thanks!

Beau Landry

Content Management Application Administrator

Continental Resources, Inc.

20 N. Broadway

OKC, OK 73102

P/F: 405.774.5963

C: 405.435.0584

Beau.landry@clr.com<mailto:Beau.landry@clr.com>

www.clr.com<http://www.clr.com/>

Mailing:

P.O. Box 269000

OKC, OK 73126

Badge +7

You could also try Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript  - when you paste your test-string as well as the regex in there, you'll even get an explanation! happy.png

Reply