# Diasabling based on role and/or remote client

**URL:** <https://forum.inductiveautomation.com/t/diasabling-based-on-role-and-or-remote-client/6575>\
**Category:** Ignition\
**Created:** [May 24, 2013, 4:29pm UTC](https://forum.inductiveautomation.com/t/diasabling-based-on-role-and-or-remote-client/6575 "2013-05-24T16:29:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Micky.Franks](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Micky.Franks](https://forum.inductiveautomation.com/u/Micky.Franks)\
**Post date:** [May 24, 2013, 4:29pm UTC](https://forum.inductiveautomation.com/t/diasabling-based-on-role-and-or-remote-client/6575/1 "2013-05-24T16:29:32Z")

</div>

Trying to accomplish two things.

1. Buttons only enabled on the gateway and not on any remote clients. Is there any particular value that I could look at to accomplish this?

2. Enabling/Disabling objects based on role of user logged in. Also have the ability to switch user after inactive time.

Basically needing two roles, control and view only. Gateway has option for both. Client only has option to view. Gateway also needs to automatically switch to view only after an inactive time.

---

<div class="post-metadata">

**Author:** ![CPowell](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CPowell](https://forum.inductiveautomation.com/u/CPowell)\
**Post date:** [May 24, 2013, 5:37pm UTC](https://forum.inductiveautomation.com/t/diasabling-based-on-role-and-or-remote-client/6575/2 "2013-05-24T17:37:43Z")

</div>

1. I would make a script to see if the client IP address and the gateway address is the same.

Then have the script called from the enable / visibilty  
Code on the button visible or enable:

```auto
runScript("app.Test.remote('{[System]Client/Network/IPAddress}')")
```

```auto
def remote(clientip):
	import system
	import re
	#Get the gateway IP addres
	gateip = system.util.getGatewayAddress()
	#Format the address to perform the check. 
	x = gateip.split("/")
	y = x[2].split(":")
	gatewayip = y[0]

	if gatewayip != clientip:
		remote = 0
	else:
		remote = 1
	#Return the result
	return remote
```

1. Add a Client Event Script under Timer.  
Call it Inactivity

```auto
if "control" in system.security.getRoles():
	if system.util.getInactivitySeconds() > 3000:
		uname = "guest"
		pwd = "guest"
		system.security.switchUser(uname,pwd)
                system.nav.goHome()
```

You could use system.security.logout() also.  
But then they can not view the project.

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![Micky.Franks](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Micky.Franks](https://forum.inductiveautomation.com/u/Micky.Franks)\
**Post date:** [May 24, 2013, 6:43pm UTC](https://forum.inductiveautomation.com/t/diasabling-based-on-role-and-or-remote-client/6575/3 "2013-05-24T18:43:22Z")

</div>

> [@CPowell](#):
>
> 1) I would make a script to see if the client IP address and the gateway address is the same.

Simple, yet very effective.
