Page 1 of 1

Function to detect if XI user is a user or admin?

Posted: Tue Oct 08, 2013 9:30 pm
by Box293
I am working on a component that I wish to restrict certain features depending if the end user type is a "user" or an "admin".

I have looked at the Object Notes component and there are two functions it uses to detect if a user can configure a service.

Code: Select all

is_authorized_to_configure_service(0,$hostname,$servicename)
is_authorized_to_configure_host(0,$hostname)
Are there any other built in functions available to detect the user type? When I say "user type" I am referring to when you are configuring a Nagios XI user account, for the option "Authorization Level" you can choose User or Admin.

Re: Function to detect if XI user is a user or admin?

Posted: Wed Oct 09, 2013 10:10 am
by sreinhardt
There is, let me dig into svn real quick and I will edit my post to reflect what it should be.

I believe all you need is the is_admin() function. If it returns false, they are not an admin, and if true... well you get the idea!

Re: Function to detect if XI user is a user or admin?

Posted: Wed Oct 09, 2013 9:22 pm
by Box293
is_admin did the trick.

Code: Select all

if(is_admin() == true) {
		$html .= 'User IS an admin';
		}
	else {
		$html .= 'User is NOT an admin';
		}
Thanks muchly.