none
How to set myself as Organizer when an MeetingInvite is sent through EWS? RRS feed

  • Question

  • Hi Team,


    I am using a EWS service to send Meeting Invite. Service Account ID for EWS is created as EXCHANGEEMAIL. As of now i am receving the MeetingInvite with From as "EXCHANGEEMAIL". As of this, I am not able to cancel/update MeetingInvite from the OutLook since I am not considered as Organizer. Need inputs on how I can set myself as Organizer instead of EXCHANGEEMAIL so that I can cancel/update MeetingInvite. 

    Below is my code and please help me with inputs..

                                                                         
     private void SendMeetingInvite(string to, string subject, string meetinglocation )
            {
                ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);                  
                NetworkCredential myCred = new NetworkCredential(ConfigurationManager.AppSettings["ServiceAccount"], ConfigurationManager.AppSettings["ServicePassword"], ConfigurationManager.AppSettings["Domain"]);

                service.Credentials = myCred;
                service.TraceEnabled = true;
                service.TraceFlags = TraceFlags.All;
                service.AutodiscoverUrl(ConfigurationManager.AppSettings["ExchangeAddress"], RedirectionUrlValidationCallback);
                Appointment meeting = new Appointment(service);

                // Set the properties on the meeting object to create the meeting.
                meeting.Subject = subject;
                meeting.Body = "This is the email I've sent by using the EWS Managed API!";
                meeting.Start = DateTime.Now.AddMinutes(15);
                meeting.End = meeting.Start.AddHours(1);
                meeting.Location = meetinglocation;
    meeting.Organizer.Name = "test";



                // attendees for meeting/required participants          
                if (!string.IsNullOrEmpty(to))
                {
                    if (to.Contains(";"))
                    {
                        string[] MailTo = Regex.Split(to, ";");
                        foreach (string To in MailTo)
                        {
                            if (!string.IsNullOrEmpty(To))
                            {
                               meeting.RequiredAttendees.Add(To);
                            }
                        }
                    }
                    else
                    {
                        meeting.RequiredAttendees.Add(to);
                    }
                }
                meeting.ReminderMinutesBeforeStart = 5;

                // Save the meeting to the Calendar folder and send the meeting request.
                meeting.Save(SendInvitationsMode.SendToAllAndSaveCopy);
                meetingId = meeting.Id.ToString();

                // Verify that the meeting was created.
                Item item = Item.Bind(service, meeting.Id, new PropertySet(ItemSchema.Subject));

                label1.Text = "Meeting Invitation is sent successfully";

    }

    Thanks

    Vamshi


    Vamshi Janagama

    Tuesday, October 6, 2015 8:41 PM

Answers

  • Okay so EXCHANGEEMAIL should be give rights to Impersonate the organizers you require.
    • Marked as answer by Vamshi K J Tuesday, October 13, 2015 5:07 PM
    Monday, October 12, 2015 3:24 AM

All replies

  • I would suggest you look at using EWS Impersonation to impersonate the organizer that you want https://msdn.microsoft.com/en-us/library/office/dd633680(v=exchg.80).aspx . Because your essentially creating the appointment as a delegate at the moment the behaviour will be simular to you accessing another calendar in Outlook. Using EWS Impersonation will allow you to act directly as the Organizer which should fix your issue.

    Cheers
    Glen

    Wednesday, October 7, 2015 1:55 AM
  • Thank You Glen.

    I have tried this option and seems permission is needed to impersonate the requested User.


    Thanks

    Vamshi


    Vamshi Janagama

    Wednesday, October 7, 2015 2:44 PM
  • You need to grant the Service Account your using EWS Impersonation rights this is done via the Application Impersonation RBAC role see https://msdn.microsoft.com/en-us/library/office/bb204095(v=exchg.140).aspx

    Cheers
    Glen

    Wednesday, October 7, 2015 10:01 PM
  • Thank You Glen for sharing the link and valuable information. 

    I have created a WCF Service with four contracts (which are SendMeetingInvite, UpdateMeetingInvite, CancelMeetingInvite, ViewMeetingResponses). This WCF Service uses Exchange Service ( ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);) to send Meeting Invites, Update Meeting Invites, Cancel Meeting Invites, View Meeting Responses based on the inputs received. I am integrating this WCF Service to a client application to allow the user to send the MeetingInvite from the application itself instead of using OutLook.

    I have went through the link and followed the below points, Need to know if this impersonation concept should be done at Client Application or in WCF Service. I need your help on this?

    To configure Exchange Impersonation for specific users or groups of users

    1.Open the Exchange Management Shell.

    2.Run the New-ManagementScope cmdlet to create a scope to which the impersonation role can be assigned. If an existing scope is available, you can skip this step. The following example shows how to create a management scope for a specific group.
    New-ManagementScope –Name:scopeName –RecipientRestrictionFilter:recipientFilter

    3.Run the New-ManagementRoleAssignment cmdlet to add the permission to impersonate the members of the specified scope. The following example shows how to configure Exchange Impersonation to enable a service account to impersonate all users in a scope.
    New-ManagementRoleAssignment –Name:impersonationAssignmentName –Role:ApplicationImpersonation –User:serviceAccount –CustomRecipientWriteScope:scopeName

    4.The RecipientRestrictionFilter parameter of the New-ManagementScope cmdlet defines the members of the scope. You can use properties of the Identity object to create the filter. The following example is a filter that restricts the result to a single user with the user name "john."
    Name –eq 'john'

    Thanks

    Vamshi


    Vamshi Janagama

    Thursday, October 8, 2015 1:12 PM
  • >>I have went through the link and followed the below points, Need to know if this impersonation concept should be done at Client Application or in WCF Service. I need your help on this?

    Neither you need to look at the security context your code is running under currently, eg from your first post you mentioned "EWS is created as EXCHANGEEMAIL",

    >> I am integrating this WCF Service to a client application to allow the user to send the MeetingInvite from the application itself instead of using OutLook.

    Okay but what credentials does your service run the EWS code as if the client can pass their credentials through to your backend server then you can impersonate those via Kerberos delegation see http://blogs.msdn.com/b/emeamsgdev/archive/2012/11/05/exchange-web-services-from-a-web-application-using-windows-authentication.aspx (In this case you don't need to use EWS impersonation)

    EWS Impersonation would be useful where you have One Service Account your using to run all you EWS code. In that case that user would be grant the rights to impersonate the Mailboxes it was going to access. There is sample of how to scope Impersonation on http://blogs.msdn.com/b/dhruvkh/archive/2011/10/19/impersonation-in-the-times-of-rbac.aspx

    Cheers
    Glen

    Friday, October 9, 2015 4:24 AM
  • Morning Glen,

    >>Neither you need to look at the security context your code is running under currently, eg from your first post you mentioned "EWS is created as EXCHANGEEMAIL",

    EXCHANGEEMAIL is an service Account address. Once a meeting invite is sent through EWS, the organizer name will show up as  EXCHANGEEMAIL@...... followed by domain name.

    Thank You

    Vamshi


    Vamshi Janagama

    Friday, October 9, 2015 1:57 PM
  • Okay so EXCHANGEEMAIL should be give rights to Impersonate the organizers you require.
    • Marked as answer by Vamshi K J Tuesday, October 13, 2015 5:07 PM
    Monday, October 12, 2015 3:24 AM
  • Thank you Glen

    Vamshi Janagama

    Tuesday, October 13, 2015 5:07 PM