Quantcast
Channel: Exchange Server Development forum
Viewing all 7132 articles
Browse latest View live

Getting all emails currently in inbox using EWS

$
0
0

I am writing an application to monitor a mailbox and log tickets for a support ticketting system.

I have it working (mostly) however I just noticed that when the monitor programme first starts up, anything already in the mailbox is ignored and not processed.

This is the code I am using to retrieve items from the mailbox, can anyone assist please? (this is called one when the application first launches, and then whenever the subscription is notified of incoming mail, so I thought it would process all current emails in there as well).

The email is then processed and moved by the receiving code (a website).

Thanks in advance!

       void CheckForItems()
        {
            // Track whether there are more items available for download on the server.
            bool moreChangesAvailable = false;

            do
            {
                // Get a list of all items in the Inbox by calling SyncFolderHierarchy repeatedly until no more changes are available.
                // The folderId parameter must be set to the root folder to synchronize,
                // and must be same folder ID as used in previous synchronization calls.
                // The propertySet parameter is set to IdOnly to reduce calls to the Exchange database,
                // because any additional properties result in additional calls to the Exchange database.
                // The ignoredItemIds parameter is set to null, so that no items are ignored.
                // The maxChangesReturned parameter is set to return a maximum of 10 items (512 is the maximum).
                // The syncScope parameter is set to Normal items, so that associated items will not be returned.
                // The syncState parameter is set to cSyncState, which should be null in the initial call,
                // and should be set to the sync state returned by the
                // previous SyncFolderItems call in subsequent calls.
                ChangeCollection<ItemChange> icc = service.SyncFolderItems(new FolderId(WellKnownFolderName.Inbox), PropertySet.IdOnly, null, 10, SyncFolderItemsScope.NormalItems,"");

                // If the count of changes is zero, there are no changes to synchronize.
                if (icc.Count == 0)
                {

                }
                else
                {
                    foreach (ItemChange ic in icc)
                    {
                        PropertySet propSet = new PropertySet(BasePropertySet.FirstClassProperties);
                        Item item = Item.Bind(this.service, ic.ItemId, propSet);

                        //-------------------------------------------------
                        //SEND ALERT HERE
                        //-------------------------------------------------
                        
                        if(this.OnNotifyEmail != null)
                            this.OnNotifyEmail(item);

                        WebRequest webRequest = WebRequest.Create(string.Format(this.ticketUrlHandler, System.Net.WebUtility.UrlEncode(item.Id.UniqueId)));
                        HttpWebResponse response = null;

                        webRequest.Timeout = 1200; //miliseconds
                        webRequest.Method = "HEAD";
                        webRequest.UseDefaultCredentials = true;

                        try
                        {
                            response = (HttpWebResponse)webRequest.GetResponse();
                        }
                        catch (WebException webException)
                        {
                            WebExceptionStatus status = webException.Status;
                            this.OnEmailError(item, webException.Message);
                        }
                        catch (Exception ex)
                        {
                            this.OnEmailError(item, ex.Message);
                        }
                        finally
                        {
                            if (response != null)
                            {
                                response.Close();
                            }
                        }

                    }
                }

                // Save the sync state for use in future SyncFolderContent requests.
                // The sync state is used by the server to determine what changes to report
                // to the client.
                string sSyncState = icc.SyncState;

                // Determine whether more changes are available on the server.
                moreChangesAvailable = icc.MoreChangesAvailable;
            }

            while (moreChangesAvailable);
        }



Integration with Outlook REST API to allow delegate access to other users' calendar

$
0
0
Here is my tidied up question:
http://stackoverflow.com/questions/35976578/outlook-read-another-users-calendar

It would be very nice to be able to retrieve my company meeting rooms' calendar using delegate permissions with Outlook API.

Many thanks!! :)

Gabriele (gabriele.sacchi-at_bjss.com)


SSO need to be used in EWS manage API

$
0
0

Hi,

We need to use SSO Authentication. Let us know how we can avoid WebCredentials.

exchangeService.Credentials = new WebCredentials(Username, PWD, Domain);

EWS - Replace text in appointment body that contains

$
0
0

Hi All,

I'm using EWS to populate an appointment body with details of events.  The value I pass through on creation of an event is formatted like this (note: the appointment itself is already present in exchange):

<p>Name<br />Address<br />score</p>

This works and is formatted in outlook as I'd like:

Name

Address

Score

There may be multiple event details added to one exchange appointment which are listed below each other but added separately:

Name

Address

Score

Name

Address

Score

This also works without an issue.

The problem is when I come to remove event details using a replace function (where appointmentText is the original string - "<p>Name<br />Address<br />score</p>") e.g.:

appointment.body.ToString().replace(appointmentText,"");

The text is not being replaced.

If I pass through a single line of text without the tags to format the details the replace works correctly but the text is less user friendly to read in the outlook appointment.

My assumption is that something happens to the string formatting after I've called the EWS but I don't know what.  I've read a little about exchange converting it to RTF.  If this is the case, are there any formatting conversion methods I can use on the appointmentText string to allow the replace function to find the string in the body?


Start and End time of edited recurrence appointment in ics file?

$
0
0

Hi Team,

I have a daily recurrence appointment with “RRULE:FREQ=DAILY;COUNT=3” and start from( DTSTART;TZID="Eastern Standard Time":20160417T000000 )and  end after( DTEND;TZID="Eastern Standard Time":20160417T020000 ), without editing recurrence appointment series when I save calendar and edit ics file I could find the DTSTART and DTEND time are same as I given but when edit the any single recurrence appointment only appointment “subject” and save the calendar and edit ics file the edited recurrence appointments DTSTART and DTEND  time are not same as I used , to ensure that I open the editor in outlook calendar I can see correct DTSTART and DTEND time of edited recurrence appointment. Could you please explain why DTSTART and DTEND  time of edited recurrence appointment get changed  in ics file and how logics works?

Replication procedure:

1.Save daily recurrence appointment with 3 recurrence count start  and end time is 12.00 am to 2.00 am.

2.Save Calendar and edit the ics file saved and check the time of start and end time of saved recurrence appointment.

3.Then come back to calendar and edit any recurrence appointment’s subject.

4. Save Calendar and edit the ics file saved and check edited recurrence appointment start and end time of edited recurrence appointment.

Thanks in advance.

Regards,

Jeyasri M


[Exchange-Online][EWS][C#][Windows] FindAppointments returns privates, while Appointment.Bind - not

$
0
0

Exchange Version: Exchange-Online/2013
IDE: MS Visual Studio 2013
Targeted features: Items synchronization

I am synchronizing room mailbox with .NET Exchange service calling SyncFolderItems (Id properties only). After I get the list of changed ID's, I try to load them. Everything works except that I can't load private appointment to get it's Start-End time. I get error: {The specified object was not found in the store., Item not found.}.

ChangeCollection<ItemChange> icc = _exchangeService.SyncFolderItems(new FolderId(WellKnownFolderName.Calendar, new Mailbox(email)),
PropertySet.IdOnly, null, 50, SyncFolderItemsScope.NormalItems, "");
foreach (ItemChange itemChange in icc)
{
  ExchangeAppointment appointment = Appointment.Bind(_exchangeService, itemChange.ItemId, PropertySet.FirstClassProperties);
}

You would think permissions right? But I can do the same thing with:

var f = new FolderId(WellKnownFolderName.Calendar, new Mailbox(email));
CalendarView cv = new CalendarView(new DateTime(2016, 4, 20, 0, 0, 0), new DateTime(2016,4,20,23,59,59));
FindItemsResults<ExchangeAppointment> items = _exchangeService.FindAppointments(f, cv);
And I get the needed private appointments.



How to Read all user account Appointment using EWS

$
0
0

Hello,

we want to read all exchange user account appointment using EWS service with ImpersonatedUser login details.

Is there any way to read all updated appointment ?

thanks

Improve Contact.Save/Update performance MS Exchange Server 2016

$
0
0

Hello everyone,

is there any way to improve the performance of the EWS managed api Contact.Save()/-Update() method on MS Exchange 2016 by throtteling?

The following cmdlets didn't have any significant impact on the performance of theContact.Save() method.

Set-ThrottlingPolicy ConnectorPolicy
    -RCAMaxConcurrency Unlimited
    -EWSMaxConcurrency Unlimited
    -EWSMaxSubscriptions Unlimited
    -CPAMaxConcurrency Unlimited
    -EwsCutoffBalance Unlimited
    -EwsMaxBurst Unlimited
    -EwsRechargeRate Unlimited
    
Set-Mailbox "Connector" -ThrottlingPolicy ConnectorPolicy

Actually, it can save up to 4 contacts per second.

Did I forget a parameter within the cmdlet?

Thank you very much in advance.


Understanding MIMETruncation and TruncationSize

$
0
0
I am reading ActiveSync Protocol document. But I could not able to figure out the below mention questions regarding following flags in Sync request

i.  MIMETruncation(in chars)
ii. BodyPreference{Type = 4, TruncationSize(in bytes)}

1. What is the difference between MIMETruncation and TruncationSize?
2. What are there default value if they are not present?
3. If both are present then which one overrides whom?
4. Also as we know a MIME mail has some predefined format so if I say a MIME mail consists of Mail Header(To, From, Subjects etc) and Mail Body(Actual content). So which truncation field apply to which part of mail(Note that there units are diffent one is number of chars and other one is in bytes)? As of now TruncationSize applies to ApplicationData->Body->Data field content.But in case of MIME email I want some clarification is it apply to Mail Body or Mail as whole(Mail Header + Mail Body).
5. Also mail at server can be stored in any format say plain, HTML, rich text so while sending mail to mobile device which type should be placed in Mail Body(HTML/PLAIN/RICH TEXT)?

How to handle Exchange Password change on client

$
0
0

I have an email client which uses EAS. Now suppose if the user of my email client sets up his email account and starts using the app. Meanwhile suppose if his password was changed (using other client or OWA) then I am supposed to show him a prompt telling him the situation and asking to log back in using the new password.

My problem is that I am not getting a way to figure out if the password was changed on the server because all I get is a sync error without any detailed reason of the error in the sync response.

Below is the error I get when I sync with a wrong credential:

"Element not found. A dialog cannot be displayed because the parent window handle has not been set."

Is there a way to identify that the password was changed for that user?


[EWSMA] [C#] [Windows] Getting UnAuthorized connecting to Office 365

$
0
0

Hello,

I have a Windows Service that uses EWS Managed API to manage a users mailbox. Everything was working fine until all of our mailboxes where moved to Office365. Since then my service stopped working and wasn't creating any errors so I created a quick console application to test the basics of EWS.

As of right now AutoDiscovery is not working because it cannot be found which I think we have a DNS issue, just not sure if server admin fixed it yet, so to make sure the rest of the stuff works I just hard code the URL. When I run the following code I get the following:

The request failed. The remote server returned an error: (401) Unauthorized.

Here is the code that I am using:

class Program
    {
        static void Main(string[] args)
        {
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
            ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

            service.Credentials = new WebCredentials("myUser", "password", "domain.com");

            try
            {
                service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");

                SendEmail(service);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadLine();
        }

private static void SendEmail(ExchangeService s)
        {
            EmailMessage message = new EmailMessage(s);
            message.Subject = "Testing EWS";
            message.Body = "This is a test
            message.ToRecipients.Add("user1@domain.com");
            message.Send();
        }
}

From what I was reading online, with Exchange 2013 you now have to provide applications created access to use EWS. Server Admin ran the following which according to Microsoft will allow it for all applications, but I still get Unauthorized and do not know why.

https://technet.microsoft.com/en-us/library/aa997443.aspx

Example 2

This example allows all client applications to use REST and EWS.

Set-OrganizationConfig -EwsApplicationAccessPolicy EnforceBlockList -EwsBlockList $null

Can anyone help me out, I am out of ideas?


If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.

Exchange 2013 - Disabled Mailbox not showing up immediately in the Connect a Mailbox

$
0
0

I have disable a mailbox  over an hour ago but it doesn’t show in the connect a mailbox section in the ECP Exchange 2013. immediately. The reason why I disable the email as I want to attach it to a new AD user which I have created.

I know you have to wait for replication so it appears in the connect a mailbox but I’m not sure how long and we forced an AD replication to see if that works.

I know with Exchange 2010, to get the disconnected mailbox to show immediately, I used to write a command Clean-MailboxDatabase “DB” to get it to appear in the disconnected mailbox but that doesn’t work with Exchange 2013 anymore.

Anyone have any suggestions?

Exchange 2016 problem with inbound and outbound

$
0
0

Hello,

I am trying to deploy Exchange server 2016 on Azure, i have 2 VMs DC01-VM and EXCH01-VM, i already installed Exchange server 2016 and configure send connector and receive connector and self-signed certificate, i Set a public IP for EXCH01-VM, 40.114.246.27, when i use remote connectivity analyzer i get the following error, and i Sent the record for the ISP and they added it, is there any way to identify the error?

Inbound Error:

Attempting to send a test email message to ayesh@next.com.jo using MX mail.next.com.jo.
               Delivery of the test email message failed.
                Additional Details
                                The server returned status code 451 - Error in processing. The server response was: 4.7.0 Temporary server error. Please try again later. PRX2 
                                Exception details:
                                Message: Error in processing. The server response was: 4.7.0 Temporary server error. Please try again later. PRX2 
                                Type: System.Net.Mail.SmtpException
                                Stack trace:
                                at System.Net.Mail.DataStopCommand.CheckResponse(SmtpStatusCode statusCode, String serverResponse)
                                at System.Net.Mail.DataStopCommand.Send(SmtpConnection conn)
                                at System.Net.Mail.SmtpClient.Send(MailMessage message)
                                at Microsoft.Exchange.Tools.ExRca.Tests.SmtpMessageTest.PerformTestReally()
                                Elapsed Time: 817 ms.

Outbound:

Attempting reverse DNS lookup for IP address 40.114.246.27.

               Reverse DNS lookup failed.

                               Additional Details

                                               IP address 40.114.246.27 doesn't have a PTR record in DNS.

Elapsed Time: 4606 ms.

i tried to add the ISP IP in myvnet same problem.

Regards,

Ayesh

Where/when automaticly created using EWS in Appointment body

$
0
0

As discussed in this thread there is still no solution by removing/hide the where/when text in a appointment body created with EWS (exchange 2013)? Our users don't want to see this tekst.

Returning unique User ID from Get-MailboxFolderPermission cmdlet

$
0
0

I'm currently trying to prepare some automation using Exchange PowerShell commandlets. I've faced some problem.

When running Get-MailboxFolderPermission cmdlet on Exchange server it's returning results, but'User' field in resultset looks like DisplayName of the user. It's not unique and I need solution that returns unique user identifier (likeSamAccountName or UserPrincipalName).

Following this post - http://serverfault.com/questions/503014/how-to-get-mailbox-folder-permissions-with-samaccountname-or-upn - I was able to useUser.ADRecipient.UserPrincipalName property, but it looks that it is available only on Exchange 2013 instance, and can't be used on earlier Exchange versions.

I've also found some PowerShell function (http://pastebin.com/MQPLJ5pC) which is resolvingDisplayName into unique user identifier.

It looks like it's possible to tie it all together, but I'm wondering if there is some simpler way achieving it.

I'm interested in solution that works on Exchange 2007, 2010 and 2013.

Any help is really appreciated.


Automatically get details about participants and timings of meeting whenever a room is booked.

$
0
0

Here i created a room resource, lets say "MeetingRoom" so when ever someone books this room for meeting, i want it to send details about organiser, participants, time & date to database and save it there.

How can it be done using EWS? I was new to EWS so please give me some advices 

Thanks in Advance.

EWS > How to fetch a particular meeting item?

$
0
0

Hello,

I am new to using EWS and want to know - how to access a particular meeting item through EWS?

I will try & explain the things further.

I want to prepare a VSTO Addin for Outlook and would like to save a UserPropoerty in the Meeting item. Next, using EWS, I would like to access that particular Meeting item & read the UserProperty or fetch a meeting item having a specific value in the UserProperty.

Can the above be achieved using EWS?

Please guide.

Thanks,


-Vinay Pugalia
If a post answers your question, please click "Mark As Answer" on that post or"Vote as Helpful".
Web : Inkey Solutions
Blog : My Blog
Email : Vinay Pugalia

Unable to get Tasks using EWS API

$
0
0

Hi,

I am trying the following Java code to get the tasks from an Exchange Server, but instead I am getting an error. I am using the latest jar. (ews-java-api-2.0.jar)

public class ExchangeTest {

	public static void main(String[] args) {
	    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
	    ExchangeCredentials credentials = new WebCredentials(<username>, <pswd>);
	    service.setCredentials(credentials);

	    try {
			service.setUrl(new URI(<serverURL>));
		} catch (URISyntaxException e) {
			e.printStackTrace();
		}

	    ItemView view = new ItemView(50);
	    FindItemsResults<Item> findResults;
        SearchFilter.SearchFilterCollection filterCollection = new SearchFilter.SearchFilterCollection();

        SearchFilter.IsEqualTo searchFilter = new SearchFilter.IsEqualTo();
        searchFilter.setPropertyDefinition(TaskSchema.Status);
        searchFilter.setValue(TaskStatus.Completed);
        filterCollection.add(searchFilter);

        try {
			//findResults = service.findItems(WellKnownFolderName.Tasks, view);					//This API call works fine
			findResults = service.findItems(WellKnownFolderName.Tasks, filterCollection, view);			//This API call throws the error
			for (Item item : findResults.getItems()){
				System.out.println(item);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

The error that is being thrown is:

microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: The specified value is invalid for property.
	at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278)
	at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267)
	at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165)
	at microsoft.exchange.webservices.data.core.ExchangeService.findItems(ExchangeService.java:985)
	at microsoft.exchange.webservices.data.core.ExchangeService.findItems(ExchangeService.java:1028)
	at microsoft.exchange.webservices.data.core.ExchangeService.findItems(ExchangeService.java:1088)
	at ExchangeTest.main(ExchangeTest.java:52)

I have tried with version 1.1.5 and was getting the same error. It is also worth noting that the same code works in WebDAV API for Exchange Server 2007.

I would be grateful for any guidance.

Microsoft.Exchange.Data.Transport.Email.EmailMessage

$
0
0

Hello,

I am using the following code to create a new Email Message.  This creates a blank Mime Document that looks just like this:

MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"

I just want to add a plain text message body to this Mime Document that is sourced from a String.  Can someone point me in the right direction.  I would like to use the built in classes in the Microsoft.Exchange APIs.

Thanks

using Microsoft.Exchange.Data.Mime;
using Microsoft.Exchange.Data.Transport.Email;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;


namespace Sandbox
{
    class Sandbox
    {
        static void Main(string[] args)
        {

            EmailMessage MyMessage = EmailMessage.Create();

            //=====
            // How to add body part to the message.




            String MessageFile = "message.txt";
            FileStream MessageFile = new FileStream(MessageFile, FileMode.Create);
            MyMessage.MimeDocument.WriteTo(MessageFile);
            ForwardedMessageFile.Close();



        }
    }
}

Appointment Categories

$
0
0

Hello,

I have an application wich copies appointments from one "reference" calendar (source) to other calendars. It uses the EWS API. Actualy it compares if there are allready copied appointments from the reference calendar of the target calendars, if yes it deletes them and copies everything again. This application is running daily for once.

Everything is working fine.

My problem is, that some users are giving some oftheir copied appointments a category over their Outlook and after the delet-copy application the categories are gone.

So what I am trying to do ist, to query the category of the appointment, delete the appointment and the reassing the catergory on that same appointment.

I have an user for impersonation and he is copying all the appointments from the reference calender to all the users (their calenders), who are in a defined ditribution group.

To query the appointment Ids I use the DDay.iCal class library.

Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Exchange.WebServices.Data;
using DDay.iCal;
using DDay.iCal.Serialization.iCalendar;

namespace TEST
{
    class Program
    {
        static void Main(string[] args)
        {
            //Instantiate the ExchangeService class+ Exchange Certificate Validation + Imparsonate
            ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
            service.Credentials = new NetworkCredential("kalenderuser", "*******");
            service.AutodiscoverUrl("kalenderuser@domain.com", RedirectionUrlValidationCallback);

            //Determine reference User Calendar
            FolderId SourceCalendarId = new FolderId(WellKnownFolderName.Calendar, "referenzuser@domain.com");
            CalendarFolder SourceCalendar = CalendarFolder.Bind(service, SourceCalendarId);

            //Distinguish Distribution Group
            string distributiongroup = "testverteiler@domain.com";

            //Determin Date to schearch
            DateTime startDate = DateTime.Now.AddDays(0);
            DateTime endDate = DateTime.Now.AddDays(6);
            CalendarView calView = new CalendarView(startDate, endDate);

            //Expand the Menbers from Distributiongroup
            ExpandGroupResults distGroupMembers = service.ExpandGroup(distributiongroup);

            //Create an Array for the caching of every Mailbox Calendar Folder
            int i = 0;
            CalendarFolder[] all_distCalender = new CalendarFolder[distGroupMembers.Members.Count()];

            foreach (EmailAddress address in distGroupMembers.Members)
            {
                //Create Calendar Folder IDs for every Mailbox
                FolderId distUserCalendarId = new FolderId(WellKnownFolderName.Calendar, address.Address);
                CalendarFolder distCalendar = CalendarFolder.Bind(service, distUserCalendarId);

                //Add the Folders in Array
                all_distCalender[i] = distCalendar;
                i++;
            }

            //Find all Appointments form reference Mailbox and copy them in Distributiongroup Members
            FindItemsResults<Appointment> termine = SourceCalendar.FindAppointments(calView);

            foreach (Appointment referenceTermine in termine)
            {
                foreach (CalendarFolder distributionCalendar in all_distCalender)
                {
                    FindItemsResults<Appointment> distCalendarTermine = distributionCalendar.FindAppointments(calView);
                    foreach (Appointment date in distCalendarTermine)
                    {
                        var Kategorie = date.Categories;

                        if (referenceTermine.ICalUid == date.ICalUid)
                        {
                            date.Delete(DeleteMode.HardDelete);
                        }
                    }
                    referenceTermine.Copy(distributionCalendar.Id);
                }
            }
        }
        public static bool RedirectionUrlValidationCallback(string redirectionUrl)
        {
            // The default for the validation callback is to reject the URL.
            bool result = false;

            Uri redirectionUri = new Uri(redirectionUrl);

            // Validate the contents of the redirection URL. In this simple validation
            // callback, the redirection URL is considered valid if it is using HTTPS
            // to encrypt the authentication credentials.
            if (redirectionUri.Scheme == "https")
            {
                result = true;
            }
            return result;
        }

        public static bool CertificateValidationCallBack(
        object sender,
        System.Security.Cryptography.X509Certificates.X509Certificate certificate,
        System.Security.Cryptography.X509Certificates.X509Chain chain,
        System.Net.Security.SslPolicyErrors sslPolicyErrors)
        {
            // If the certificate is a valid, signed certificate, return true.
            if (sslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
            {
                return true;
            }

            // If there are errors in the certificate chain, look at each error to determine the cause.
            if ((sslPolicyErrors & System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors) != 0)
            {
                if (chain != null && chain.ChainStatus != null)
                {
                    foreach (System.Security.Cryptography.X509Certificates.X509ChainStatus status in chain.ChainStatus)
                    {
                        if ((certificate.Subject == certificate.Issuer) &&
                           (status.Status == System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.UntrustedRoot))
                        {
                            // Self-signed certificates with an untrusted root are valid.
                            continue;
                        }
                        else
                        {
                            if (status.Status != System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
                            {
                                // If there are any other errors in the certificate chain, the certificate is invalid,
                                // so the method returns false.
                                return false;
                            }
                        }
                    }
                }

                // When processing reaches this line, the only errors in the certificate chain are
                // untrusted root errors for self-signed certificates. These certificates are valid
                // for default Exchange server installations, so return true.
                return true;
            }
            else
            {
                // In all other cases, return false.
                return false;
            }
        }
    }
}

Have you any idea how can I achieve this?

Thank you

Ioannis

Viewing all 7132 articles
Browse latest View live




Latest Images