Aracılığıyla paylaş


Nasıl yapılır: Görüntülemek ve Yayımcı ve dağıtımcı özellikleri (rmo programlama) Değiştir

Programlı olarak görüntülemek ve Publisher ve dağıtımcı özelliklerini kullanarak değiştirmek Çoğaltma Yönetim Nesneleri (rmo).

Dağıtıcı özelliklerini görüntüleme ve değiştirme için

  1. Dağıtıcı bir bağlantı kullanarak oluşturmak ServerConnection WalkTree

  2. Oluşturma bir örnek , ReplicationServer WalkTreePASS ServerConnection Adım 1 nesnesinden.

  3. (İsteğe bağlı) Kontrol IsDistributor özellik denetlemek için şu anda bağlı sunucuyu olduğundan dağıtıcı.

  4. Call Load yöntem alma özelliklerinden server.

  5. (İsteğe bağlı) Özelliklerini değiştirmek için küme bir veya daha fazla olabilir dağıtıcı özellik için yeni bir değer küme , ReplicationServer nesne.

  6. (İsteğe bağlı) CachePropertyChanges özellik ReplicationServer nesne küme true, çağrı CommitPropertyChanges yöntem server. değişiklikleri kaydetmeyi

Dağıtım veritabanı özelliklerini görüntüleme ve değiştirme için

  1. Dağıtıcı bir bağlantı kullanarak oluşturmak ServerConnection WalkTree

  2. Oluşturma bir örnek , DistributionDatabase WalkTreeName özellik belirtin ve geçmesi ServerConnection Adım 1 nesnesinden.

  3. Call LoadProperties yöntem alma özelliklerinden server.Bu yöntem döndürür, false, veritabanı belirtilen adı taşıyan mevcut değil sunucu.

  4. (İsteğe bağlı) Özelliklerini değiştirmek için yeni bir değer biri için küme DistributionDatabase özellikleri, olabilir küme.

  5. (İsteğe bağlı) CachePropertyChanges özellik DistributionDatabase nesne küme true, çağrı CommitPropertyChanges yöntem server. değişiklikleri kaydetmeyi

Yayımcı özelliklerini görüntüleme ve değiştirme için

  1. Bir bağlantı oluşturmak Yayımcı kullanarak ServerConnection WalkTree

  2. Oluşturma bir örnek , DistributionPublisher WalkTreeBelirtmek Name özellik ve geçişi ServerConnection Adım 1 nesnesinden.

  3. (İsteğe bağlı) Özelliklerini değiştirmek için yeni bir değer biri için küme DistributionPublisher özellikleri, olabilir küme.

  4. (İsteğe bağlı) CachePropertyChanges özellik DistributionPublisher nesne küme true, çağrı CommitPropertyChanges yöntem server. değişiklikleri kaydetmeyi

Yönetici bağlantısı için parolayı değiştirmek için Yayımcı için dağıtıcı

  1. Dağıtıcı bir bağlantı kullanarak oluşturmak ServerConnection WalkTree

  2. Oluşturma bir örnek , ReplicationServer WalkTree

  3. Set ConnectionContext özellik için adım 1'de oluşturduğunuz bağlantı.

  4. Call Load yöntem alma özelliklerinin nesne.

  5. Call ChangeDistributorPassword yöntem.Yeni parola değeri iletmek password parametresi.

    Güvenlik notuGüvenlik Notu

    Mümkün olduğunda, zamanında güvenlik kimlik bilgileri bilgilerini girmesini ister.Kimlik bilgileri saklamanız gerekir kullanın Şifreleme Hizmetleri tarafından sağlanan WindowsMicrosoft .net Framework.

  6. (İsteğe bağlı) Bu dağıtımcı kullanan her bir uzak yayımcı adresindeki parolayı değiştirmek için aşağıdaki adımları uygulayın:

    1. Bir bağlantı oluşturmak Yayımcı kullanarak ServerConnection WalkTree

    2. Oluşturma bir örnek , ReplicationServer WalkTree

    3. Set ConnectionContext Adım 6a. oluşturulan bağlantı özellik

    4. Call Load yöntem alma özelliklerinin nesne.

    5. Call ChangeDistributorPassword yöntem.Yeni parola değeri için adım 5'den geçmesi password parametresi.

Örnek

Bu örnek, dağıtım ve dağıtım veritabanı özelliklerini değiştirmek nasıl gösterir.

Güvenlik notuGüvenlik Notu

Kod, kimlik bilgileri bilgilerini depolama önlemek için yeni dağıtımcı parola zamanında sağlanır.

          // 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