I am trying to configure a merge replication between a the publisher (SQL Server 2008 R2) and several clients running SQL 2008 R2 Express. I have created separate local windows logins for merge, distrubution and snapshot agents. Everything works fine if I use Sync Center on clients to replicate, but I cant get it to work when using RMO.
The problem is that I dont know how to connect with RMO using the dedicated merge account that Im using with Sync Center or a client that has the SQL Server Agent with the replication job.
Does anybody know best practice for this?
Here is a code snippet that I am using:
ServerConnection conn = new ServerConnection(subscriberName);
MergePullSubscription subscription;
conn.Connect();
subscription = new MergePullSubscription();
subscription.ConnectionContext = conn;
subscription.DatabaseName = subscriptionDbName;
subscription.PublisherName = publisherName;
subscription.PublicationDBName = publicationDbName;
subscription.PublicationName = publicationName;
if (subscription.LoadProperties())
{
agent = subscription.SynchronizationAgent;
agent.PublisherSecurityMode = SecurityMode.Integrated;
agent.DistributorSecurityMode = SecurityMode.Integrated;
agent.Distributor = publisherName;
agent.OutputVerboseLevel = 4;
agent.Output = "C:\\TEMP\\mergeagent.log";
agent.Status += new AgentCore.StatusEventHandler(agent_Status);
agent.Synchronize();
}