# Getting firstname and lastname in Active Directory

**URL:** <https://forum.inductiveautomation.com/t/getting-firstname-and-lastname-in-active-directory/22746>\
**Category:** Ignition Early Access\
**Created:** [February 21, 2019, 3:39am UTC](https://forum.inductiveautomation.com/t/getting-firstname-and-lastname-in-active-directory/22746 "2019-02-21T03:39:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudipta.tripathy](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@sudipta.tripathy](https://forum.inductiveautomation.com/u/sudipta.tripathy)\
**Post date:** [February 21, 2019, 3:39am UTC](https://forum.inductiveautomation.com/t/getting-firstname-and-lastname-in-active-directory/22746/1 "2019-02-21T03:39:42Z")

</div>

Is it possible to get first name and last name in AD user sources? I was wondering if I could define sn , and givenName for the first name attribute. If I set the first name attribute to **name** and use the following code I only get last name.

users = system.user.getUsers(“adsource”)  
for user in users:  
name=user.get(user.FirstName)  
print name

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 22, 2019, 7:50pm UTC](https://forum.inductiveautomation.com/t/getting-firstname-and-lastname-in-active-directory/22746/2 "2019-02-22T19:50:00Z")

</div>

Using the onboard default User Source this script worked perfectly for me (all users returned and user.FirstName obtained their first name instead of their surname). I’ll ask around to see if we’d expect differently from an AD user source, but as of right now I’m not able to replicate the behavior…

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [February 22, 2019, 7:55pm UTC](https://forum.inductiveautomation.com/t/getting-firstname-and-lastname-in-active-directory/22746/3 "2019-02-22T19:55:27Z")

</div>

I got it working with our AD using the following:

```auto
users = system.user.getUsers("adsource")
for user in users:
	first=user.get(user.FirstName)
	last=user.get(user.LastName)
	print first, last

```
