MonitoringUserRole Class

Updated: April 16, 2012

Specifies an assigned user role that contains a scope and users. Namespace: Microsoft.EnterpriseManagement.Monitoring.Security
Assembly: Microsoft.EnterpriseManagement.OperationsManager (in Microsoft.EnterpriseManagement.OperationsManager.dll)Dim instance As MonitoringUserRole <SerializableAttribute> _ Public Class MonitoringUserRole Inherits UserRole[SerializableAttribute] public class MonitoringUserRole : UserRole[SerializableAttribute] public ref class MonitoringUserRole : public UserRole/** @attribute SerializableAttribute() */ public class MonitoringUserRole extends UserRoleSerializableAttribute public class MonitoringUserRole extends UserRole

The following example shows how to use the MonitoringUserRole class to retrieve the user roles and their members for each user role in the Management Group.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Monitoring;
using Microsoft.EnterpriseManagement.Security;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Xml;
using Microsoft.EnterpriseManagement.Monitoring.Security;

namespace SDKSamples
	class Program
		static void Main(string[] args)
			ManagementGroup managementGroup = new ManagementGroup("localhost");
			IList<UserRole> roles = managementGroup.Security.GetUserRoles();

			foreach (MonitoringUserRole role in roles)
				Console.WriteLine("Role Name: {0}", role.DisplayName);

				if (role.Users.Count == 0)
					Console.WriteLine("\tNo users are in this role");
					foreach (string userName in role.Users)
						Console.WriteLine("\t{0}", userName);

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows Server 2003, and

Target Platforms