Setting the Administrative Port Identity
When a configuration database is created, the current application pool identity for SharePoint Central Administration is stored in the configuration database in the format DOMAIN\Account_Name. When a new computer is connected to the configuration database, Microsoft Windows SharePoint Services 2.0 verifies that the new application pool identity matches the identity stored in the configuration database. If the identities do not match, the operation to connect the new computer does not succeed.
To connect a new computer to the configuration database after changing the application pool identity, the identity that is stored in the configuration database must be set to the new identity. The following code example shows how to set the application pool identity by using the Properties property of the SPGlobalConfig class.
[Visual Basic .NET]
Dim spGlobalAdmin As New SPGlobalAdmin()
spGlobalAdmin.Config.Properties("AdminPortIdentity") = "Identity"
spGlobalAdmin.Config.Properties.Update()
spGlobalAdmin.Close()
[C#]
SPGlobalAdmin spGlobalAdmin = new SPGlobalAdmin();
spGlobalAdmin.Config.Properties["AdminPortIdentity"] = "Identity";
spGlobalAdmin.Config.Properties.Update();
spGlobalAdmin.Close();
The global string AdminPortIdentity is used as an indexer on the Properties property, which returns an SPPropertyBag object representing properties of the configuration database. The Update method must be used for changes to take effect in the database, and the Close method is used to release the resources consumed by the SPGlobalAdmin object.
In the context of a server farm, create separate instances of the SPGlobalAdmin class to modify the administrative port identity and to refresh the configuration cache, as in the following example.
[Visual Basic .NET]
Dim globalAdmin1 As SPGlobalAdmin = Nothing
Dim globalAdmin2 As SPGlobalAdmin = Nothing
Try
globalAdmin1 = New SPGlobalAdmin()
globalAdmin1.RefreshConfigCache()
globalAdmin2 = New SPGlobalAdmin()
globalAdmin2.Config.Properties("AdminPortIdentity") = "Identity"
globalAdmin2.Config.Properties.Update()
Finally
If Nothing <> globalAdmin1 Then
globalAdmin1.Close()
End If
If Nothing <> globalAdmin2 Then
globalAdmin2.Close()
End If
End Try
[C#]
SPGlobalAdmin globalAdmin1 = null;
SPGlobalAdmin globalAdmin2 = null;
try
{
globalAdmin1 = new SPGlobalAdmin();
globalAdmin1.RefreshConfigCache();
globalAdmin2 = new SPGlobalAdmin();
globalAdmin2.Config.Properties["AdminPortIdentity"] = "Identity";
globalAdmin2.Config.Properties.Update();
}
finally
{
if (null != globalAdmin1)
{
globalAdmin1.Close();
}
if (null != globalAdmin2)
{
globalAdmin2.Close();
}
}