# Scripting Get User Password

**URL:** <https://forum.inductiveautomation.com/t/scripting-get-user-password/59313>\
**Category:** Ignition\
**Tags:** ignition81, vision, scripting\
**Created:** [May 6, 2022, 6:16pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313 "2022-05-06T18:16:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [May 6, 2022, 6:16pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/1 "2022-05-06T18:16:10Z")

</div>

I am able to get user info through scripting using the following script:

```auto
defaultUser = system.user.getUser("","default")
defaultUsername = defaultUser.get("username")

```

However, this returns nothing:

```auto
defaultUser = system.user.getUser("","default")
defaultPassword = defaultUser.get("password")

```

Are we not allowed to access user passwords through scripting?

I’m wanting to do this so that I can auto-sign in the default user after other users sign out, and have it still work after the default user password changes

---

<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:** [May 6, 2022, 6:27pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/2 "2022-05-06T18:27:02Z")

</div>

No. For security reasons, user passwords are not typically stored in a manner that would allow their retrieval.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [May 6, 2022, 6:31pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/3 "2022-05-06T18:31:47Z")

</div>

Ok, then I guess my solution would be to make it so the default account’s password can’t be changed (from within the client anyway).

I’m trying to use the `filterRole()` extension function, but it doesn’t seem to be working quite as I expected.

```auto
if !userLogged:
		return 0

	elif role == "Guest":
		return 0
	else:
		return 1

```

Results in this table:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/5/05ab37174cff293150f54ce5dde1f8f7deaa4a9f.png)  
Why is the “default” user not hidden?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 6, 2022, 7:06pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/4 "2022-05-06T19:06:04Z")

</div>

> [@amarks](#):
>
> Why is the “default” user not hidden?

It looks like your logic isn't correct.

```auto
if role in ('Guest','default') or not userLogged:
	return 0
else:
	return 1

```

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [May 6, 2022, 7:35pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/5 "2022-05-06T19:35:54Z")

</div>

That did not fix the issue, and I really didn’t expect it to. Why would the `filterRoles()` extension function look at the username?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 6, 2022, 7:47pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/6 "2022-05-06T19:47:09Z")

</div>

Oops, I looked at `default` as a role instead of username. It should have still worked since there isn’t a `default` role to worry about. The `filterRole()` extension function customizes the list of roles not the list of users. `filterRole()` is applied to user management component’s role table if it has `Role Management Enabled` property selected. You should add a script to the `filterUser()` extension function

```auto
if 'Guest' in user.getRoles():
	return 0
else: 
	return 1

```

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [May 6, 2022, 7:52pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/7 "2022-05-06T19:52:56Z")

</div>

Thanks for the help.  
This is what ended up working in the `filterUser()` extension function:

```auto
if user.get("username") == "default" or !userLoggedIn:
		return 0
	else:
		return 1

```

this works as well:

```auto
if "Guest" in user.getRoles() or !userLoggedIn:
		return 0
	else:
		return 1

```

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 6, 2022, 7:55pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/8 "2022-05-06T19:55:55Z")

</div>

That works too, but if you add another user with the `Guest` role it won’t filter it out. It’s fine if `default` is the only one that will have the `Guest` role. If userLoggedIn is a boolean, then the correct syntax is to use `not`.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [May 6, 2022, 7:59pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/9 "2022-05-06T19:59:38Z")

</div>

Practically, there will be little to no difference between `!` and `not` in this case

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 6, 2022, 8:00pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/10 "2022-05-06T20:00:29Z")

</div>

If I’m not mistaken `!` isn’t a python operator. The bitwise not operator is `~`.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [May 6, 2022, 8:09pm UTC](https://forum.inductiveautomation.com/t/scripting-get-user-password/59313/11 "2022-05-06T20:09:48Z")

</div>

You are correct, by it still seemed to work ¯\_(ツ)\_/¯
