MonitoringUserRole Class

System Center

Updated: April 16, 2012

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

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)

'Usage
Dim instance As MonitoringUserRole

[SerializableAttribute] 
public ref class MonitoringUserRole : public UserRole
/** @attribute SerializableAttribute() */ 
public class MonitoringUserRole extends UserRole
SerializableAttribute 
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");
                }
                else
                {
                    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

 

Community Additions

ADD
Show: