Reverse lookup an Account Name from a User Profile field

  • 20 November 2015
  • 6 replies
  • 2 views

Badge +3

In essence what I want to do is look up a user's Account Name from the SharePoint User Profile Service by inputting another unique field. In this case it is a custom Employee ID field in the UPS that is read from AD, but it could be by phone number, or other fields.

 

To clarify, I am inputting an Employee ID number and wanting to extract the username that matches up with the Employee ID.

 

I've tried setting a variable as shown in the attached file, but that errors out with "Workflow failed to get user profile for user".

 

I have confirmed that the property is readable from the User Profile service in Nintex, by using a Query User Profile action, hard-coding a user in and emailing the Employee ID number.

 

Thanks for any advice!


6 replies

Badge +3

I believe I found a solution. I used a Query LDAP action to grab the displayName that matches up with the Employee ID. I can now work with the UPS using the displayName and Query User Profile action.

Not sure if there's a way to do this directly with the UPS or not, but the LDAP solution should work.

Badge +5

Hi Josh.

 

Yes,"Query LDAP" should work. Another alternative to do this within a workflow is to use "Web Request" to make a "Get" REST service call.

 

http://siteurl/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='EmployeeID')?@v='domainusername'

 

This applies to both SharePoint Online and on-prem.

 

More info can be found: Vardhaman Deshpande: SharePoint 2013: Get UserProfile Properties with REST API

 

I have used this to populate form data through javascript from clientside but i am sure this should work serverside as well.

 

Regards,

Thomas

Badge +3

Thanks, I was curious if it could be done with the UPS directly. I'll try that out when I have more time. The LDAP query is working for me for the time being.

Badge +5

My apologies. Yesh Query User Profile only accepts account name as input parameter .

Badge +2

Hello Josh Lindemann‌,   Can you please let me know what query you used in LDAP action picker.

I have same requirement like yours, I need to pass EmployeeID and get Account Name. but only problem at my end is we have users from multiple domains. 

Badge +3

Inside a For Each loop, I compare everyone in AD against the employee ID number. Inside the For Each there is a Query LDAP action that tries to match the Emp ID # to an AD account.

The query is simply: (employeeID={WorkflowVariable:varEmployeeID}) and the properties I'm retrieving when it finds a match are displayName and userPrincipalName

Reply