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

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

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

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

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

Post 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!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

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

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked