How to Connect to a Management Group Server
Applies To: System Center 2012 - Service Manager
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
To connect to a Service Manager data store, use the EnterpriseManagementGroup class. This class connects to the data store and is also your access point for reading and writing information to and from the data store. The same method of connecting is used whether you are creating a one-time application to accomplish a specific task or a long-term solution that will regularly communicate with the data store.
At minimum, the server you are connecting to must be specified; localhost can be used when you connect locally. Because the connection is under the credentials of the current process, you can use one of the EnterpriseManagementGroup constructors to specify additional settings for the connection, such as credentials.
To connect to a server with default credentials
- Create an instance of the EnterpriseManagementGroup class, specifying the location of the server.
To connect to a server with specific credentials
Create an instance of the EnterpriseManagementConnectionSettings class, specifying the location of the server.
Set the UserName, Domain and Password properties.
Create an instance of the EnterpriseManagementGroup class, passing in the reference to the EnterpriseManagementConnectionSettings class.
Example
The following example demonstrates how to connect to the server by the use of default credentials.
EnterpriseManagementGroup mg = new EnterpriseManagementGroup("localhost");
The following example demonstrates how to connect to the server by the use of specific credentials.
EnterpriseManagementConnectionSettings settings = new EnterpriseManagementConnectionSettings("localhost");
settings.UserName = "MyUserName";
settings.Domain = "MyDomain";
settings.Password = new System.Security.SecureString();
foreach (char letter in new char[] { 'M', 'y', 'P', 'a', 's', 's', 'w', 'o', 'r', 'd' })
{
settings.Password.AppendChar(letter);
}
EnterpriseManagementGroup mg = new EnterpriseManagementGroup(settings);
Compiling the Code
Namespaces
Microsoft.EnterpriseManagement |
System |
Assemblies
Microsoft.EnterpriseManagement.Core |
System |
Security
When using the System.Security.SecureString type, make sure that you do not convert a System.String type into a System.Char array type and then use it to fill the Password property. If you do, the password is exposed as plain text in memory when it exists as a String type.
See Also
Reference
EnterpriseManagementGroup
EnterpriseManagementConnectionSettings