ReplicationServer.ChangeDistributorPassword ReplicationServer.ChangeDistributorPassword ReplicationServer.ChangeDistributorPassword Method

Definition

Changes the Distributor password.

Overloads

ChangeDistributorPassword(SecureString) ChangeDistributorPassword(SecureString) ChangeDistributorPassword(SecureString)

Changes the Distributor password, where the new password is supplied as a SecureString object.

ChangeDistributorPassword(String) ChangeDistributorPassword(String) ChangeDistributorPassword(String)

Changes the Distributor password.

ChangeDistributorPassword(SecureString) ChangeDistributorPassword(SecureString) ChangeDistributorPassword(SecureString)

Changes the Distributor password, where the new password is supplied as a SecureString object.

public:
 void ChangeDistributorPassword(System::Security::SecureString ^ password);
public void ChangeDistributorPassword (System.Security.SecureString password);
Public Sub ChangeDistributorPassword (password As SecureString)

Parameters

password
SecureString SecureString SecureString

The new Distributor password is a SecureString value.

Security Note When possible, prompt users to enter security credentials at run time. If you must store credentials, use the http://go.microsoft.com/fwlink/?LinkId=34733 cryptographic services provided by the Windows .NET Framework.

Remarks

The DistributorInstalled property must be true to set this property.

The ChangeDistributorPassword(SecureString) method provides additional security for the password while it is stored in memory and should be used instead of ChangeDistributorPassword(String).

The ChangeDistributorPassword method can be called by members of the sysadmin fixed server role at the Distributor.

The ChangeDistributorPassword method is equivalent to the sp_changedistributor_password (Transact-SQL) stored procedure.

ChangeDistributorPassword(String) ChangeDistributorPassword(String) ChangeDistributorPassword(String)

Changes the Distributor password.

public:
 void ChangeDistributorPassword(System::String ^ password);
public void ChangeDistributorPassword (string password);
Public Sub ChangeDistributorPassword (password As String)

Parameters

password
String String String

The new password string for the distributor_admin login.

Security Note When possible, prompt users to enter security credentials at run time. If you must store credentials, use the http://go.microsoft.com/fwlink/?LinkId=34733 cryptographic services provided by the Windows .NET Framework.

Examples

// Set the Distributor and distribution database names.
string distributionDbName = "distribution";
string distributorName = publisherInstance;

ReplicationServer distributor;
DistributionDatabase distributionDb;

// Create a connection to the Distributor using Windows Authentication.
ServerConnection conn = new ServerConnection(distributorName);

try
{
    // Open the connection. 
    conn.Connect();

    distributor = new ReplicationServer(conn);

    // Load Distributor properties, if it is installed.
    if (distributor.LoadProperties())
    {
        // Password supplied at runtime.
        distributor.ChangeDistributorPassword(password);
        distributor.AgentCheckupInterval = 5;

        // Save changes to the Distributor properties.
        distributor.CommitPropertyChanges();
    }
    else
    {
        throw new ApplicationException(
            String.Format("{0} is not a Distributor.", publisherInstance));
    }

    // Create an object for the distribution database 
    // using the open Distributor connection.
    distributionDb = new DistributionDatabase(distributionDbName, conn);

    // Change distribution database properties.
    if (distributionDb.LoadProperties())
    {
        // Change maximum retention period to 48 hours and history retention 
        // period to 24 hours.
        distributionDb.MaxDistributionRetention = 48;
        distributionDb.HistoryRetention = 24;

        // Save changes to the distribution database properties.
        distributionDb.CommitPropertyChanges();
    }
    else
    {
        // Do something here if the distribution database does not exist.
    }
}
catch (Exception ex)
{
    // Implement the appropriate error handling here. 
    throw new ApplicationException("An error occured when changing Distributor " +
        " or distribution database properties.", ex);
}
finally
{
    conn.Disconnect();
}

Remarks

The DistributorInstalled property must be true to set this property.

The ChangeDistributorPassword method can be called by members of the sysadmin fixed server role at the Distributor.

The ChangeDistributorPassword method is equivalent to the sp_changedistributor_password (Transact-SQL) stored procedure.

See also

Applies to