ReplicationServer.ChangeDistributorPassword メソッド

定義

ディストリビューターのパスワードを変更します。

オーバーロード

ChangeDistributorPassword(SecureString)

ディストリビューターのパスワードを変更します。新しいパスワードは SecureString オブジェクトとして指定されます。

ChangeDistributorPassword(String)

ディストリビューターのパスワードを変更します。

ChangeDistributorPassword(SecureString)

ディストリビューターのパスワードを変更します。新しいパスワードは SecureString オブジェクトとして指定されます。

public:
 void ChangeDistributorPassword(System::Security::SecureString ^ password);
public void ChangeDistributorPassword (System.Security.SecureString password);
member this.ChangeDistributorPassword : System.Security.SecureString -> unit
Public Sub ChangeDistributorPassword (password As SecureString)

パラメーター

password
SecureString

ディストリビューターの新しいパスワードは、SecureString 値です。

セキュリティメモ 可能な場合は、実行時にセキュリティ資格情報の入力をユーザーに求めます。 資格情報を格納する必要がある場合は、Windows .NET Frameworkによって提供される暗号化サービスを使用http://go.microsoft.com/fwlink/?LinkId=34733します。

注釈

このプロパティを設定するには、DistributorInstalled プロパティに true を設定する必要があります。

ChangeDistributorPassword(SecureString) メソッドでは、パスワードがメモリに保持されている間のセキュリティが強化されています。パスワードを設定するときには、ChangeDistributorPassword(String) ではなく、このメソッドを使用してください。

ChangeDistributorPassword メソッドを呼び出すことができるのは、ディストリビューター側の固定サーバー ロール sysadmin のメンバーです。

メソッドは ChangeDistributorPasswordsp_changedistributor_password (Transact-SQL) ストアド プロシージャと同じです。

適用対象

ChangeDistributorPassword(String)

ディストリビューターのパスワードを変更します。

public:
 void ChangeDistributorPassword(System::String ^ password);
public void ChangeDistributorPassword (string password);
member this.ChangeDistributorPassword : string -> unit
Public Sub ChangeDistributorPassword (password As String)

パラメーター

password
String

distributor_admin ログインの新しいパスワード文字列です。

セキュリティメモ 可能な場合は、実行時にセキュリティ資格情報の入力をユーザーに求めます。 資格情報を格納する必要がある場合は、Windows .NET Frameworkによって提供される暗号化サービスを使用http://go.microsoft.com/fwlink/?LinkId=34733します。

// 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();
}

注釈

このプロパティを設定するには、DistributorInstalled プロパティに true を設定する必要があります。

ChangeDistributorPassword メソッドを呼び出すことができるのは、ディストリビューター側の固定サーバー ロール sysadmin のメンバーです。

メソッドは ChangeDistributorPasswordsp_changedistributor_password (Transact-SQL) ストアド プロシージャと同じです。

こちらもご覧ください

適用対象