방법: 게시자 및 배포자 속성 보기 및 수정(RMO 프로그래밍)

RMO(복제 관리 개체)를 사용하여 프로그래밍 방식으로 게시자 및 배포자 속성을 보고 수정할 수 있습니다.

배포자 속성을 보고 수정하려면

  1. ServerConnection 클래스를 사용하여 배포자 연결을 만듭니다.

  2. ReplicationServer 클래스의 인스턴스를 만듭니다. 1단계에서 만든 ServerConnection 개체를 전달합니다.

  3. (옵션) IsDistributor 속성에서 현재 연결된 서버가 배포자인지 확인합니다.

  4. Load 메서드를 호출하여 서버에서 속성을 가져옵니다.

  5. (옵션) 속성을 변경하려면 ReplicationServer 개체에 설정할 수 있는 하나 이상의 배포자 속성에 새 값을 설정합니다.

  6. (옵션) ReplicationServer 개체의 CachePropertyChanges 속성이 true로 설정되면 CommitPropertyChanges 메서드를 호출하여 서버의 변경 내용을 커밋합니다.

배포 데이터베이스 속성을 보고 수정하려면

  1. ServerConnection 클래스를 사용하여 배포자 연결을 만듭니다.

  2. DistributionDatabase 클래스의 인스턴스를 만듭니다. 이름 속성을 지정하고 1단계에서 만든 ServerConnection 개체를 전달합니다.

  3. LoadProperties 메서드를 호출하여 서버에서 속성을 가져옵니다. 이 메서드가 false를 반환하는 경우 지정된 이름의 데이터베이스가 서버에 없는 것입니다.

  4. (옵션) 속성을 변경하려면 설정할 수 있는 DistributionDatabase 속성 중 하나에 대해 새 값을 설정합니다.

  5. (옵션) DistributionDatabase 개체의 CachePropertyChanges 속성이 true로 설정되면 CommitPropertyChanges 메서드를 호출하여 서버의 변경 내용을 커밋합니다.

게시자 속성을 보고 수정하려면

  1. ServerConnection 클래스를 사용하여 게시자 연결을 만듭니다.

  2. DistributionPublisher 클래스의 인스턴스를 만듭니다. Name 속성을 지정하고 1단계에서 만든 ServerConnection 개체를 전달합니다.

  3. (옵션) 속성을 변경하려면 설정할 수 있는 DistributionPublisher 속성 중 하나에 대해 새 값을 설정합니다.

  4. (옵션) DistributionPublisher 개체의 CachePropertyChanges 속성이 true로 설정되면 CommitPropertyChanges 메서드를 호출하여 서버의 변경 내용을 커밋합니다.

관리 연결의 암호를 게시자에서 배포자로 변경하려면

  1. ServerConnection 클래스를 사용하여 배포자 연결을 만듭니다.

  2. ReplicationServer 클래스의 인스턴스를 만듭니다.

  3. ConnectionContext 속성을 1단계에서 만든 연결로 설정합니다.

  4. Load 메서드를 호출하여 개체 속성을 얻습니다.

  5. ChangeDistributorPassword 메서드를 호출합니다. password 매개 변수에 대해 새 암호 값을 전달합니다.

    보안 정보보안 정보

    가능하면 런타임에 사용자에게 자격 증명을 입력하라는 메시지를 표시하십시오. 자격 증명을 저장해야 하는 경우 Microsoft Windows .NET Framework에서 제공하는 암호화 서비스를 사용합니다.

  6. (옵션) 다음 단계를 수행하여 이 배포자를 사용하는 각 원격 게시자에서 암호를 변경합니다.

    1. ServerConnection 클래스를 사용하여 게시자 연결을 만듭니다.

    2. ReplicationServer 클래스의 인스턴스를 만듭니다.

    3. ConnectionContext 속성을 6a단계에서 만든 연결로 설정합니다.

    4. Load 메서드를 호출하여 개체 속성을 얻습니다.

    5. ChangeDistributorPassword 메서드를 호출합니다. password 매개 변수에 대해 5단계에서 만든 새 암호 값을 전달합니다.

이 예에서는 배포 및 배포 데이터베이스 속성을 변경하는 방법을 보여 줍니다.

보안 정보보안 정보

자격 증명을 코드에 저장하지 않도록 런타임에 새 배포자 암호가 제공됩니다.

         // 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();
            }
' Set the Distributor and distribution database names.
Dim distributionDbName As String = "distribution"
Dim distributorName As String = publisherInstance

Dim distributor As ReplicationServer
Dim distributionDb As DistributionDatabase

' Create a connection to the Distributor using Windows Authentication.
Dim conn As ServerConnection = New ServerConnection(distributorName)

Try
    ' Open the connection. 
    conn.Connect()

    distributor = New ReplicationServer(conn)

    ' Load Distributor properties, if it is installed.
    If distributor.LoadProperties() Then
        ' 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))
    End If

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

    ' Change distribution database properties.
    If distributionDb.LoadProperties() Then
        ' 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.
    End If
Catch ex As Exception
    ' Implement the appropriate error handling here. 
    Throw New ApplicationException("An error occured when changing Distributor " + _
        " or distribution database properties.", ex)
Finally
    conn.Disconnect()
End Try