Inserts the specified secure data object into the management group.
Namespace: Microsoft.EnterpriseManagement
Assembly: Microsoft.EnterpriseManagement.OperationsManager
(in microsoft.enterprisemanagement.operationsmanager.dll)
Usage
Syntax
Parameters
- secureData
-
The secure data to insert.
Example
The following example demonstrates a use of the
InsertMonitoringSecureData method to insert a new RunAs
action account.
C# |
Copy Code |
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Monitoring;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Xml;
using Microsoft.EnterpriseManagement.Monitoring.Security;
using System.Security;
namespace SDKSamples
{
class Program
{
static void Main(string[] args)
{
MonitoringActionAccountSecureData runAsAccount;
ManagementGroup managementGroup;
SecureString password;
managementGroup = new ManagementGroup("localhost");
password = new SecureString();
runAsAccount = new MonitoringActionAccountSecureData();
runAsAccount.Domain = "Contoso";
runAsAccount.UserName = "MonitoringAccount";
runAsAccount.Name = "Contoso\\MonitoringAccount";
runAsAccount.Description = "Sample Run As account";
Console.WriteLine("Please enter the password");
while (true)
{
ConsoleKeyInfo cki = Console.ReadKey(true);
if (cki.Key == ConsoleKey.Enter)
{
break;
}
else if (cki.Key == ConsoleKey.Backspace)
{
if (password.Length > 0)
{
Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
Console.Write(" ");
Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
password.RemoveAt(password.Length - 1);
}
}
else if (cki.Key == ConsoleKey.Escape)
{
Console.WriteLine("Password not entered");
return;
}
else if (Char.IsLetterOrDigit(cki.KeyChar) || Char.IsSymbol(cki.KeyChar))
{
password.AppendChar(cki.KeyChar);
Console.Write("*");
}
else
{
Console.Beep();
}
}
runAsAccount.SecureData = password;
managementGroup.InsertMonitoringSecureData(runAsAccount);
}
}
}
|
Thread Safety
Any public static (Shared in Visual
Basic) members of this type are thread safe. Any instance members
are not guaranteed to be thread safe.
Platforms
Development Platforms
Windows Server 2008, Windows Vista, Windows Server 2003, and
Windows XP
Target Platforms
Windows Server 2008,Windows Server 2003,Windows Vista,Windows
XP
See Also