How to find a users AD account name based on a display name with the Query LDAP action

Blog Post created by Employee on Apr 26, 2015

Often times we have an Active Directory (AD) username that we need to find a users display name for. This type of lookup is well documented  here on the Nintex Connect community site.  But what about the opposite scenario?  What if I have a text display name and I want to get the username?


So, I decide to write up a quick post (as I was helping someone the other day that was saving user names to a text column in SharePoint and then wanted to go back and lookup their AD account information) to describe how to perform this type of lookup. Thankfully, this is pretty straightforward to accomplish with the Query LDAP action in Nintex Workflow.


Example and how to


I have a user with a display name of 'John Doe' and I want to find his LANID which is 'jdoe123'


Open the Nintex workflow designer and drag the Query LDAP action to your canvas:



Now you'll need to configure the action. I have configured the action to retrieve the sAMAccountNAme attribute (which is the username I want to work with) and store it to a variable called perLANID. Note that this is a person type variable which would work great if I'm storing the data back in a Person / Group SharePoint column. Optionally, I could also store it to a text variable and just have the naked username.


Keep in mind that you will need to configure the LDAP path, which can be done easily by click on the grey servers icon on the right and exploring the LDAP tree that your SharePoint environment is connected to or by specifying another LDAP catalog by manually entering its path):

Here is the LDAP search query I used for your convenience:




Just to make sure everything is configured properly, you can test your configuration by clicking on Run Now (Green play button) and then clicking on Execute (Green play button):



As you can see I was able to isolate the username and can now do whatever I need to do with this account information such as assign tasks, modify permissions and more.  It's worth pointing out that while I used a hard coded value for the display name I was searching for, I could have easily substituted that with a text display name that was stored in a SharePoint column or Nintex Workflow variable.


If you find searching for metadata stored inside of AD to be helpful in your workflows I would recommend the following links for further reading:


Microsoft TechNet - LDAP Query Basics


Microsoft Technet - All AD Attributes