Exchange 2010 Impersonation Etiketli Yazılar

C# – Exchange 2010 Impersonation

Exchange 2010 üzerinden mail atarken Impersonation kullanmak gerekiyorsa, ilk olarak Impersonation Mail adresine Exchange Console dan aşağıdaki komut satırı ile yetki açmalısınız;

ew-ManagementRoleAssignment -Name:_suImpersonateRoleAsg -Role:ApplicationImpersonation -User:'mail@domain.com'

 

Exchange 2010 üzerinden Impersonation kullanarak mail göderimi için servis yapılandırılmasını da aşağıdaki method ile sağlayabilirsiniz.

using Exchange2010;

static ExchangeServiceBinding service = new ExchangeServiceBinding();

    public static void InitMSExchange(string mailadres,string DomainName,string ImperUser,string imperPass, string serviceurl )
    {
        service.RequestServerVersionValue = new RequestServerVersion();
        service.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2010;
        ServicePointManager.ServerCertificateValidationCallback = delegate(Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            return true;
        };
        service.EnableDecompression = true;
        service.UseDefaultCredentials = true;
        service.PreAuthenticate = true;
        service.Credentials = new NetworkCredential(ImperUser, imperPass, DomainName);
        service.Url = serviceurl ;
        //Imporsonate
        service.ExchangeImpersonation = new ExchangeImpersonationType()
        {
            ConnectingSID = new ConnectingSIDType()
            {
                ItemElementName = ItemChoiceType.PrimarySmtpAddress,
                Item = mailadres
            }
        };
    }