# Cannot get user name and role name in Global Script Library

**URL:** <https://forum.inductiveautomation.com/t/cannot-get-user-name-and-role-name-in-global-script-library/15806>\
**Category:** Ignition\
**Created:** [October 29, 2017, 12:31pm UTC](https://forum.inductiveautomation.com/t/cannot-get-user-name-and-role-name-in-global-script-library/15806 "2017-10-29T12:31:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason.ma](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@jason.ma](https://forum.inductiveautomation.com/u/jason.ma)\
**Post date:** [October 29, 2017, 12:31pm UTC](https://forum.inductiveautomation.com/t/cannot-get-user-name-and-role-name-in-global-script-library/15806/1 "2017-10-29T12:31:34Z")

</div>

Ignition version 7.9.4  
I want to get client user , role ,IP address then insert these information to database when tag value change.  
So I write a script in Global Script Library and call it in tag value change event:  
user = system.security.getUsername()  
role = system.security.getRoles()  
clientIP = system.tag.read("[System]Client/Network/IPAddress").value

But I get a error message in Tag Diagnostic:  
AttributeError: ‘com.inductiveautomation.ignition.common.script.Imm’ object has no attribute ‘getRoles’

And the IP address inserted into database displayed as “None”.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 29, 2017, 12:53pm UTC](https://forum.inductiveautomation.com/t/cannot-get-user-name-and-role-name-in-global-script-library/15806/2 "2017-10-29T12:53:05Z")

</div>

You can only get the username and roles when your script is executing in the scope of a client.

A tag value change script executes on the gateway and has no user associated with it.

---

<div class="post-metadata">

**Author:** ![jason.ma](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@jason.ma](https://forum.inductiveautomation.com/u/jason.ma)\
**Post date:** [October 29, 2017, 2:38pm UTC](https://forum.inductiveautomation.com/t/cannot-get-user-name-and-role-name-in-global-script-library/15806/3 "2017-10-29T14:38:09Z")

</div>

Thanks for reply!  
Why the IP address inserted to database displayed as “None”, even if I write the IP address to an memory string tag it also be “None”?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 30, 2017, 3:04pm UTC](https://forum.inductiveautomation.com/t/cannot-get-user-name-and-role-name-in-global-script-library/15806/4 "2017-10-30T15:04:18Z")

</div>

Because the tag you’re trying to read (`[System]Client/Network/IPAddress`) doesn’t have a value in the gateway scope where you’re reading it from. If you want the current system’s address in a way that works on all scopes, then you should use either [system.net.getIPAddress](https://docs.inductiveautomation.com/display/DOC79/system.net.getIpAddress) or [system.net.getExternalIpAddress](https://docs.inductiveautomation.com/display/DOC79/system.net.getExternalIpAddress).
