How to get list of Users[MailBoxes] in Exchange Server 2013 by using EWS Managed API
Hi all,
I need list of Users exists in my Exchange server 2013 , i.e Mail Box Users login name.
I was created Full Access permissions of all users to Admin user account, to access each user Mailbox programatically
i need the list of Mailboxes in exchange server .
MailBox mailbox = new MailBox("user");
Please share your ideas
Hi,
We can run the following command in Exchange Management Shell to get all user mailboxes name and export it to a .csv file:
Get-Mailbox -ResultSize Unlimited | Select Name,Alias,RecipientTypeDetails | Export-Csv c:\Users.csv
If you want to retrieve the list of users by using EWS Managed API, I suggest you can ask a question in Exchange Development forum for more suggestion:
http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/threads
Regards,
Winnie Liang
TechNet Community Support
Similar Messages
-
Get list of User Mailboxes in Exchange server 2013 by using EWS managed API
Hi all,
I need list of Users exists in my Exchange server 2013 , i.e Mail Box Users log in name.
i know the command in Powershell to get list, but i need this using code[ ews managed API].
How can i achieve this ?
Please share your ideasHi Glen,
i follow your suggested links i wrote below code ,
here i am getting error
The term 'Get-Users' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
SecureString password = new SecureString();
string str_password = "EIS2014!@#";
string username = "[email protected]";
foreach (char x in str_password) { password.AppendChar(x); }
PSCredential credential = new PSCredential(username, password);
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("http://ExchangeServer.admin.com/powershell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);
//connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo);
PowerShell powershell = PowerShell.Create();
PSCommand command = new PSCommand();
command.AddCommand("Get-Users");
command.AddParameter("ResultSize", 50);
powershell.Commands = command;
runspace.Open();
powershell.Runspace = runspace;
var aa = powershell.Invoke();
Please help me. -
How to get list of user connected to project server by day wise
HI,
I need to get a report as how many times user is connected to the project server in a week.
I have enabled web analytical reports but its showing only how many times a user is connected to site.I need date also
Project server 2010 version.
Can any one help me.
EX:
Resource name Date Connected (yes/No)
Vijay kumar 1-11-2014 yes
Vijay kumar 2-11-2014 yes
Vijay kumar 3-11-2014 no
Vijay kumar 4-11-2014 yes
Vijay kumar 5-11-2014 yes
Vijay kumar 6-11-2014 no
Vijay kumar 7-11-2014 yes
Thank You, Kumar KSVWhat Badal Ratra gave you would be the basis for your query to populate your own table...Project Server does not give you a way to do a daily connect report
One of the ways I would go about doing this would be to run a nightly query to update a table - fill it in with the necessary data and run your report off that newly created table
High Level Steps:
(1) Create a table in the Reporting Database call DailyVisits
(1a) The table would have Name/Date/Connected columns
(1b) You wouldn't need a no answer for connected columns since the answer would always be yes, the result set would ONLY have users who connected for each day. And really you would only need 2 columns since the "connected" column would always
be Yes...
(2) Create a query that would query the published database (msp_resources) for the current day and store the result set in the table DailyVisits
(3) Put this query in a nightly task to append to the DailyVisits table @ 11:55pm (for example)
(4) Let the query run and you'll have only the users who connected for that day - the DailyVisits table would represent users who visited every day.
As long as the query runs nightly you'll have the information you're looking for - the one caveat is that it will only be starting from the day you start running the query.
You could also append the older user (last_connect) information from the resources table from other users to populate the dates but that would only represent a single entry/single last connect date. This "old" information would represent the
base for the table.
hth -
How to get list of users who reset password using FIM portal
How to get list of users who reset password using FIM portal
-Thanks Rakesh SawantHi Rakesh,
I think you are looking for something like this:
Using Powershell to list all users that had completed
a password reset within the last 30 days
If you found my post helpful, please give it a Helpful vote. If it answered your question, remember to mark it as an Answer. -
Trying to retrieve list of rooms using EWS Managed API but it returned empty collection
Hi,
I'm trying to retrieve list of rooms using EWS Managed API. Before I have tried the following code I make sure our Administrator put all the rooms in a list following link https://technet.microsoft.com/en-us/library/ee633471%28v=exchg.141%29.aspx.
Here is the simple code I have used :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Exchange.WebServices.Data;
using System.Net;
using System.Security;
namespace ExchangeConsole1
class Program
static void Main(string[] args)
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new NetworkCredential("username", "Password1", "domain");
service.Url = new Uri("https://email.xxxx.com/ews/exchange.asmx");
EmailMessage email = new EmailMessage(service);
EmailAddressCollection listOfRoomList = service.GetRoomLists();
// Display the individual rooms.
foreach (EmailAddress address in listOfRoomList)
Console.WriteLine("Email Address: {0}", address.Address);
service.GetRoomLists() results "Enumeration yielded no results". Could anybody help me please ?
Thanks
SandipanEnable tracing and see what the response from the server looks like. Also depending on your setup and how long ago your administrator created the list, it may take some
time to replicate.
Administrator has done it one week ago. Here is the trace response I am getting
<Trace Tag="EwsResponse" Tid="9" Time="2015-04-10 15:36:37Z" Version="15.00.0847.030">
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="995" MinorBuildNumber="31" Version="V2_15" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:GetRoomListsResponse ResponseClass="Success" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseCode>NoError</m:ResponseCode>
<m:RoomLists />
</m:GetRoomListsResponse>
</s:Body>
</s:Envelope>
</Trace>
It's say no error. Any help ?
Thanks
Sandipan -
How to delete/drop all the tables from SQL Server Database without using Enterprise Manager?
I tried using DROP Tables, Truncate Database, Delete and many more but it is not working. I want to delete all tables using Query Analyzer, i.e. through SQL Query.
Please help me out in this concern.
Nishith ShahInformative thread indeed. Wish I saw it early enough. Managed to come up with the code below before I saw this thread.
declare @TTName Table
(TableSchemaTableName
varchar
(500),
[status] int
default 0);
with AvailableTables
(TableSchemaTableName)
as
(select
QUOTENAME(TABLE_SCHEMA)
+
+
QUOTENAME(TABLE_NAME)
from
INFORMATION_SCHEMA.TABLES)
insert into @TTName
(TableSchemaTableName)
select *
from AvailableTables
declare @TableSchemaTableName varchar
(500)
declare @sqlstatement nvarchar
(1000)
while 1=1
begin
set @sqlstatement
=
'DROP TABLE '
+ @TableSchemaTableName
exec
sp_executeSQL
@sqlstatement
print
'Dropped Table : '
+ @TableSchemaTableName
update @TTName
set [status]
= 1
where TableSchemaTableName
= @TableSchemaTableName
if
(select
count([Status])
from @TTName
where [Status]
= 0)
= 0
break
end -
public void ShareCalendar(Calendar calendar)
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.Credentials = new NetworkCredential("user1", "password", "domain");
service.Url = new Uri("https://sampleUrl/ews/exchange.asmx");
try
// Bind to the folder
//Folder folderStoreInfo;
//folderStoreInfo = Folder.Bind(service, calendar.ExchangeId);
//string EwsID = folderStoreInfo.Id.UniqueId;
string EwsID = calendar.FolderExchangeId;
// The value of folderidHex will be what we need to use for the FolderId in the xml file
AutodiscoverService autoDiscover = new AutodiscoverService(ExchangeVersion.Exchange2013);
autoDiscover.Credentials = new NetworkCredential("user1", "password", "domain");
autoDiscover.RedirectionUrlValidationCallback = RedirectionUrlValidationCallback;
Dictionary<string, string> userSettings = GetUserSettings(autoDiscover);
string folderidHex = GetConvertedEWSIDinHex(service, EwsID, "[email protected]");
string domainName = string.Empty;
string mailBoxServer = string.Empty;
string userName = string.Empty;
foreach (var item in userSettings)
switch (item.Key)
case "UserDN":
domainName = item.Value.ToString();
break;
case "InternalMailboxServer":
mailBoxServer = item.Value.ToString();
break;
case "UserDisplayName":
userName = item.Value.ToString();
break;
string entryId = GetIntiatorEntryID(domainName);
string mailboxId = GetInvitationMailboxId(mailBoxServer, domainName);
string sharedFilePath = CreateSharingMessageAttachment(folderidHex, userName, entryId, mailboxId, "user[email protected]", "calendar", calendar.FolderName);
// Create a new message
EmailMessage invitationRequest = new EmailMessage(service);
invitationRequest.Subject = "I'd like to share my calendar with you";
invitationRequest.Body = "Sent by Exchange Administrator on behalf of user";
//invitationRequest.Culture = "en-US";
invitationRequest.Sensitivity = Sensitivity.Normal;
// Set a sharing specific property on the message
invitationRequest.ItemClass = "IPM.Sharing"; /* Constant Required Value [MS-ProtocolSpec] */
byte[] byteEntryId = HexStringToByteArray(entryId);
// This is the Guid of the Sharing Provider in Exchange, and it's value does not change
Guid binSharingProviderGuid = new Guid("{AEF00600-0000-0000-C000-000000000046}");
// Even though I don't think setting this property is mandatory,
// it just seemed like the right thing to do and it works so I \
// ain't messin with it!
byte[] byteSharingProviderGuid = binSharingProviderGuid.ToByteArray();
string strPRBODYHTML = "<html dir=\"ltr\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\r\n<meta name=\"GENERATOR\"
content=\"MSHTML 8.00.7601.17514\">\r\n<style id=\"owaParaStyle\">P {\r\n MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px \r\n}\r\n</style>\r\n</head>\r\n<body fPStyle=\"1\" ocsi=\"0\">\r\n<tt>\r\n<pre>SharedByUserDisplayName
(SharedByUserSmtpAddress) has invited you to view his or her Microsoft Exchange Calendar.\r\n\r\nFor instructions on how to view shared folders on Exchange, see the following article:\r\n\r\nhttp://go.microsoft.com/fwlink/?LinkId=57561\r\n\r\n*~*~*~*~*~*~*~*~*~*\r\n\r\n</pre>\r\n</tt>\r\n<div>\r\n<div
style=\"direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;\">this is a test message</div>\r\n</div>\r\n</body>\r\n</html>\r\n";
string strBODY = @"
SharedByUserDisplayName (SharedByUserSmtpAddress) has invited you to view his or
her Microsoft Exchange Calendar.
For instructions on how to view shared folders on Exchange, see the
following article:
http://go.microsoft.com/fwlink/?LinkId=57561
*~*~*~*~*~*~*~*~*~*
test body
// Convert these to hex and binary equivelants to assign to their relevant
// extended properties
string hexPRBODYHTML = ConvertStringToHex(strPRBODYHTML);
byte[] binPRBODYHTML = HexStringToByteArray(hexPRBODYHTML);
Guid PropertySetSharing = Guid.Parse("00062040-0000-0000-C000-000000000046");//constant
Guid PropertySetInternetHeaders = Guid.Parse("00020386-0000-0000-C000-000000000046");//constant
ExtendedPropertyDefinition PidLidSharingProviderGuidProperty = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A01, MapiPropertyType.CLSID);
ExtendedPropertyDefinition ConversationIdProperty = new ExtendedPropertyDefinition(0x3013, MapiPropertyType.Binary);
// Sharing Properties (in order of reference according to protocol examples in: [MS-OXSHARE])
// Additional Property Constraints
// [MS-OXSHARE] 2.2.5.2
ExtendedPropertyDefinition PidTagMessageClass = new ExtendedPropertyDefinition(0x001A, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.5.1
//ExtendedPropertyDefinition PidNameContentClass = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "Content-Class", MapiPropertyType.String);
ExtendedPropertyDefinition PidNameContentClass = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "Content-class", MapiPropertyType.String);
// Common Message Object Properties
// [MS-OXSHARE] 2.2.1
ExtendedPropertyDefinition PidTagNormalizedSubject = new ExtendedPropertyDefinition(0x0E1D, MapiPropertyType.String);
// The PidTagSubjectPrefix is a zero-length string, so I do not set it
// ExtendedPropertyDefinition PidTagSubjectPrefix = new ExtendedPropertyDefinition(0x003D, MapiPropertyType.String);
// Sharing Object Message Properties
// [MS-OXSHARE] 2.2.2.12
ExtendedPropertyDefinition PidLidSharingProviderGuid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A01, MapiPropertyType.Binary);
// [MS-OXSHARE] 2.2.2.13
ExtendedPropertyDefinition PidNameXSharingProviderGuid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-GUID", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.14
ExtendedPropertyDefinition PidLidSharingProviderName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A02, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.15
ExtendedPropertyDefinition PidNameXSharingProviderName = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-Name", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.16
ExtendedPropertyDefinition PidLidSharingProviderUrl = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A03, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.17
ExtendedPropertyDefinition PidNameXSharingProviderUrl = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-URL", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.5
ExtendedPropertyDefinition PidLidSharingFlavor = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A18, MapiPropertyType.Integer);
// [MS-OXSHARE] 2.2.2.6
ExtendedPropertyDefinition PidNameXSharingFlavor = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Flavor", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.1
ExtendedPropertyDefinition PidLidSharingCapabilities = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A17, MapiPropertyType.Integer);
// [MS-OXSHARE] 2.2.2.2
ExtendedPropertyDefinition PidNameXSharingCapabilities = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Capabilities", MapiPropertyType.String);
// Sections 2.3 and 2.4 are also zero-length strings, so I won't set those either
// [MS-OXSHARE] 2.2.2.3
// ExtendedPropertyDefinition PidLidSharingConfigurationUrl = new //ExtendedPropertyDefinition(PropertySetSharing, 0x8A24, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.4
//ExtendedPropertyDefinition PidNameXSharingConfigUrl = new //ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "X-Sharing-Config-Url", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.10
ExtendedPropertyDefinition PidLidSharingLocalType = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A14, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.11
ExtendedPropertyDefinition PidNameXSharingLocalType = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Local-Type", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.7
ExtendedPropertyDefinition PidLidSharingInitiatorEntryId = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A09, MapiPropertyType.Binary);
// [MS-OXSHARE] 2.2.2.8
ExtendedPropertyDefinition PidLidSharingInitiatorName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A07, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.9
ExtendedPropertyDefinition PidLidSharingInitiatorSMTP = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A08, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.1
ExtendedPropertyDefinition PidLidSharingRemoteName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A05, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.2
ExtendedPropertyDefinition PidNameXSharingRemoteName = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Name", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.5
ExtendedPropertyDefinition PidLidSharingRemoteType = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A1D, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.6
ExtendedPropertyDefinition PidNameXSharingRemoteType = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Type", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.7
ExtendedPropertyDefinition PidLidSharingRemoteUid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A06, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.8
ExtendedPropertyDefinition PidNameXSharingRemoteUid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Uid", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.3
ExtendedPropertyDefinition PidLidSharingRemoteStoreUid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A48, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.4
ExtendedPropertyDefinition PidNameXSharingRemoteStoreUid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Store-Uid", MapiPropertyType.String);
//From troubleshooting I noticed I was missing
ExtendedPropertyDefinition PidTagPriority = new ExtendedPropertyDefinition(0x0026, MapiPropertyType.Integer);
ExtendedPropertyDefinition PidTagSensitivity = new ExtendedPropertyDefinition(0x0036, MapiPropertyType.Integer);
ExtendedPropertyDefinition PR_BODY_HTML = new ExtendedPropertyDefinition(0x1013, MapiPropertyType.Binary); //PR_BOD
ExtendedPropertyDefinition PR_BODY = new ExtendedPropertyDefinition(0x1000, MapiPropertyType.String);
ExtendedPropertyDefinition RecipientReassignmentProhibited = new ExtendedPropertyDefinition(0x002b, MapiPropertyType.Boolean);
// Section 2.2.1
invitationRequest.SetExtendedProperty(PidTagNormalizedSubject, "I'd like to share my calendar with you"); /* Constant Required Value [MS-OXSHARE] 2.2.1 */
//invitationRequest.SetExtendedProperty(PidTagSubjectPrefix, String.Empty); /* Constant Required Value [MS-OXSHARE] 2.2.1 */
// Section 2.2.2
invitationRequest.SetExtendedProperty(PidLidSharingCapabilities, 0x40220); /* value for Special Folders */
invitationRequest.SetExtendedProperty(PidNameXSharingCapabilities, "40220"); /* Test representation of SharingCapabilities value */
//invitationRequest.SetExtendedProperty(PidLidSharingConfigurationUrl, String.Empty); /* Zero-Length String [MS-OXSHARE] 2.2.2.3 */
//invitationRequest.SetExtendedProperty(PidNameXSharingConfigUrl, String.Empty); /* Zero-Length String [MS-OXSHARE] 2.2.2.4 */
invitationRequest.SetExtendedProperty(PidLidSharingFlavor, 0x20310); /* Indicates Invitation for a special folder [MS-OXSHARE] 2.2.2.5 */
invitationRequest.SetExtendedProperty(PidNameXSharingFlavor, "20310"); /* Text representation of SharingFlavor value [MS-OXSHARE] 2.2.2.6 */
invitationRequest.SetExtendedProperty(PidLidSharingInitiatorEntryId, byteEntryId); /* Value from the Initiator/EntryId value in the Sharing Message attachment .xml document */
invitationRequest.SetExtendedProperty(PidLidSharingInitiatorSMTP, "[email protected]"); /* Value from Initiator/Smtp Address in the Sharing message attachment .xml document */
invitationRequest.SetExtendedProperty(PidLidSharingInitiatorName, "User1"); /* Value from Initiator/Name Address in the Sharing message attachment .xml document */
invitationRequest.SetExtendedProperty(PidLidSharingLocalType, "IPF.Appointment"); /* MUST be set to PidTagContainerClass of folder to be shared */
invitationRequest.SetExtendedProperty(PidNameXSharingLocalType, "IPF.Appointment"); /* MUST be set to same value as PidLidSharingLocalType */
invitationRequest.SetExtendedProperty(PidLidSharingProviderGuid, byteSharingProviderGuid); /* Constant Required Value [MS-OXSHARE] 2.2.2.12 */
invitationRequest.SetExtendedProperty(PidNameXSharingProviderGuid, "AEF0060000000000C000000000000046"); /* Constant Required Value [MS-OXSHARE] 2.2.2.13 */
invitationRequest.SetExtendedProperty(PidLidSharingProviderName, "Microsoft Exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.14 */
invitationRequest.SetExtendedProperty(PidNameXSharingProviderName, "Microsoft Exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.15] */
invitationRequest.SetExtendedProperty(PidLidSharingProviderUrl, "http://www.microsoft.com/exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.16 */
invitationRequest.SetExtendedProperty(PidNameXSharingProviderUrl, "http://www.microsoft.com/exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.17 */
// Section 2.2.3
invitationRequest.SetExtendedProperty(PidLidSharingRemoteName, calendar.FolderName); /* MUST be set to PidTagDisplayName of the folder being shared */
invitationRequest.SetExtendedProperty(PidNameXSharingRemoteName, calendar.FolderName); /* MUST be set to same value as PidLidSharingRemoteName */
invitationRequest.SetExtendedProperty(PidLidSharingRemoteStoreUid, mailboxId); /* Must be set to PidTagStoreEntryId of the folder being shared */
invitationRequest.SetExtendedProperty(PidNameXSharingRemoteStoreUid, mailboxId); /* MUST be set to same value as PidLidSharingRemoteStoreUid */
invitationRequest.SetExtendedProperty(PidLidSharingRemoteType, "IPF.Appointment"); /* Constant Required Value [MS-OXSHARE] 2.2.3.5 */
invitationRequest.SetExtendedProperty(PidNameXSharingRemoteType, "IPF.Appointment"); /* Constant Required Value [MS-OXSHARE] 2.2.3.6 */
invitationRequest.SetExtendedProperty(PidLidSharingRemoteUid, folderidHex); /* MUST be set to PidTagEntryId of folder being shared */
invitationRequest.SetExtendedProperty(PidNameXSharingRemoteUid, folderidHex); /* Must be set to same value as PidLidSharingRemoteUid */
// Section 2.2.5
invitationRequest.SetExtendedProperty(PidNameContentClass, "Sharing"); /* Constant Required Value [MS-ProtocolSpec] */
invitationRequest.SetExtendedProperty(PidTagMessageClass, "IPM.Sharing"); /* Constant Required Value [MS-ProtocolSpec] */
// ********* ADDITIONAL MAPPED PROPERTIES IM FINDING AS I TROUBLESHOOT ********************** //
invitationRequest.SetExtendedProperty(PidTagPriority, 0); /* From troubleshooting I'm just trying to match up values that were missing */
invitationRequest.SetExtendedProperty(PidTagSensitivity, 0); /* From troubleshooting as well */
invitationRequest.SetExtendedProperty(PR_BODY_HTML, binPRBODYHTML); /* From troubleshooting OWA error pointing to serializing HTML failing */
invitationRequest.SetExtendedProperty(PR_BODY, strBODY);
invitationRequest.SetExtendedProperty(RecipientReassignmentProhibited, true); /* Because it seemed like a good idea */
// Add a file attachment by using a stream
// We need to do the following in order to prevent 3 extra bytes from being prepended to the attachment
string sharMetadata = File.ReadAllText(sharedFilePath, Encoding.ASCII);
byte[] fileContents;
UTF8Encoding encoding = new System.Text.UTF8Encoding();
fileContents = encoding.GetBytes(sharMetadata);
//fileContents = File.ReadAllBytes(sharedFilePath);
//// fileContents is a Stream object that represents the content of the file to attach.
invitationRequest.Attachments.AddFileAttachment("sharing_metadata.xml", fileContents);
////invitationRequest.Attachments.AddFileAttachment(sharedFilePath);
//// This is where we set those "special" headers and other pertinent
//// information I noted in Part 1 of this series...
//Attachment thisAttachment = invitationRequest.Attachments[0];
//thisAttachment.ContentType = "application/x-sharing-metadata-xml";
//thisAttachment.Name = "sharing_metadata.xml";
//thisAttachment.IsInline = false;
// Add recipient info and send message
invitationRequest.ToRecipients.Add(new EmailAddress() { Address = "[email protected]" });
invitationRequest.SendAndSaveCopy();
// I always end my methods by returning the EWS
// impersonated user to null to clean up
service.ImpersonatedUserId = null;
catch (Exception ex)
public String GetConvertedEWSIDinHex(ExchangeService esb, String sID, String strSMTPAdd)
// Create a request to convert identifiers.
AlternateId objAltID = new AlternateId();
objAltID.Format = IdFormat.EwsId;
objAltID.Mailbox = strSMTPAdd;
objAltID.UniqueId = sID;
//Convert PR_ENTRYID identifier format to an EWS identifier.
AlternateIdBase objAltIDBase = esb.ConvertId(objAltID, IdFormat.HexEntryId);
AlternateId objAltIDResp = (AlternateId)objAltIDBase;
return objAltIDResp.UniqueId.ToString();
public String GetInvitationMailboxId(string mailBoxServer, string domainName)
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "[email protected]");
// Generate The Store Entry Id for the impersonated user
StringBuilder MailboxIDPointer = new StringBuilder();
string fqdn = mailBoxServer;
string legacyDN = domainName;
MailboxIDPointer.Append("00000000"); /* Flags */
MailboxIDPointer.Append("38A1BB1005E5101AA1BB08002B2A56C2"); /* ProviderUID */
MailboxIDPointer.Append("00"); /* Version */
MailboxIDPointer.Append("00"); /* Flag */
MailboxIDPointer.Append("454D534D44422E444C4C00000000"); /* DLLFileName */
MailboxIDPointer.Append("00000000"); /* Wrapped Flags */
MailboxIDPointer.Append("1B55FA20AA6611CD9BC800AA002FC45A"); /* WrappedProvider UID (Mailbox Store Object) */
MailboxIDPointer.Append("0C000000"); /* Wrapped Type (Mailbox Store) */
MailboxIDPointer.Append(ConvertStringToHex(fqdn)); /* ServerShortname (FQDN) */
MailboxIDPointer.Append("00"); /* termination bit */
MailboxIDPointer.Append(ConvertStringToHex(legacyDN)); /* Returns the userDN of the impersonated user */
MailboxIDPointer.Append("00"); /* terminator bit */
service.ImpersonatedUserId = null;
return MailboxIDPointer.ToString();
static bool RedirectionUrlValidationCallback(String redirectionUrl)
bool redirectionValidated = false;
if (redirectionUrl.Equals("https://SampleUrl/autodiscover/autodiscover.xml"))
redirectionValidated = true;
return redirectionValidated;
public String GetIntiatorEntryID(string domainName)
String result = String.Empty;
//// Bind to EWS
//ExchangeService service = ExchangeConnection.ExchangeService();
//service.ImpersonatedUserId =
//new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "[email protected]");
//// Get LegacyDN Using the function above this one
string sharedByLegacyDN = domainName;
// A conversion function from earlier
string legacyDNinHex = ConvertStringToHex(sharedByLegacyDN);
StringBuilder addBookEntryId = new StringBuilder();
addBookEntryId.Append("00000000"); /* Flags */
addBookEntryId.Append("DCA740C8C042101AB4B908002B2FE182"); /* ProviderUID */
addBookEntryId.Append("01000000"); /* Version */
addBookEntryId.Append("00000000"); /* Type - 00 00 00 00 = Local Mail User */
addBookEntryId.Append(legacyDNinHex); /* Returns the userDN of the impersonated user */
addBookEntryId.Append("00"); /* terminator bit */
result = addBookEntryId.ToString();
//service.ImpersonatedUserId = null;
return result;
public string ConvertStringToHex(string input)
// Take our input and break it into an array
char[] arrInput = input.ToCharArray();
String result = String.Empty;
// For each set of characters
foreach (char element in arrInput)
if (String.IsNullOrEmpty(result))
result = String.Format("{0:X2}", Convert.ToUInt16(element)).ToString();
else
result += String.Format("{0:X2}", Convert.ToUInt16(element)).ToString();
return result.ToString();
public string CreateSharingMessageAttachment(string folderid, string userSharing, string userSharingEntryID, string invitationMailboxID, string userSharedTo, string dataType, string calendarName)
XmlDocument sharedMetadataXML = new XmlDocument();
string sharedMetaDataFilePath = string.Empty;
try
// Create a String that contains our new sharing_metadata.xml file
StringBuilder metadataString = new StringBuilder("<?xml version=\"1.0\"?>");
metadataString.Append("<SharingMessage xmlns=\"http://schemas.microsoft.com/sharing/2008\">");
metadataString.Append("<DataType>" + dataType + "</DataType>");
metadataString.Append("<Initiator>");
metadataString.Append("<Name>" + userSharing + "</Name>");
metadataString.Append("<SmtpAddress>" + "[email protected]" + "</SmtpAddress><EntryId>" + userSharingEntryID.Trim());
metadataString.Append("</EntryId>");
metadataString.Append("</Initiator>");
metadataString.Append("<Invitation>");
metadataString.Append("<Title>" + calendarName + "</Title>");
metadataString.Append("<Providers>");
metadataString.Append("<Provider Type=\"ms-exchange-internal\" TargetRecipients=\"" + userSharedTo + "\">");
metadataString.Append("<FolderId xmlns=\"http://schemas.microsoft.com/exchange/sharing/2008\">");
metadataString.Append(folderid);
metadataString.Append("</FolderId>");
metadataString.Append("<MailboxId xmlns=\"http://schemas.microsoft.com/exchange/sharing/2008\">");
metadataString.Append(invitationMailboxID);
metadataString.Append("</MailboxId>");
metadataString.Append("</Provider>");
metadataString.Append("</Providers>");
metadataString.Append("</Invitation>");
metadataString.Append("</SharingMessage>");
sharedMetadataXML.LoadXml(metadataString.ToString());
string tempPath = System.IO.Path.GetTempPath();
sharedMetaDataFilePath = tempPath + "sharing_metadata.xml";
sharedMetadataXML.Save(sharedMetaDataFilePath);
catch (Exception eg)
throw eg;
return sharedMetaDataFilePath;
public Dictionary<string, string> GetUserSettings(AutodiscoverService autodiscoverService)
GetUserSettingsResponse userresponse = autodiscoverService.GetUserSettings(
"[email protected]",
UserSettingName.UserDisplayName,
UserSettingName.InternalMailboxServerDN,
UserSettingName.UserDN
Dictionary<string, string> myUserSettings = new Dictionary<string, string>();
foreach (KeyValuePair<UserSettingName, Object> usersetting in userresponse.Settings)
if (usersetting.Key.ToString() == "InternalMailboxServerDN")
int lastIndexOfEqual = usersetting.Value.ToString().LastIndexOf("=");
string subString = usersetting.Value.ToString().Substring(lastIndexOfEqual + 1);
string value = subString;
myUserSettings.Add("InternalMailboxServer", value.ToString());
if (usersetting.Key.ToString() == "UserDisplayName")
string[] arrResult = usersetting.Value.ToString().Split('.');
myUserSettings.Add("UserDisplayName", arrResult[0].ToString());
if (usersetting.Key.ToString() == "UserDN")
string[] arrResult = usersetting.Value.ToString().Split('.');
myUserSettings.Add("UserDN", arrResult[0].ToString());
return myUserSettings;
private static byte[] HexStringToByteArray(string input)
byte[] Bytes;
int ByteLength;
string HexValue = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9|||||||\xA\xB\xC\xD\xE\xF";
ByteLength = input.Length / 2;
Bytes = new byte[ByteLength];
for (int x = 0, i = 0; i < input.Length; i += 2, x += 1)
Bytes[x] = (byte)(HexValue[Char.ToUpper(input[i + 0]) - '0'] << 4);
Bytes[x] |= (byte)(HexValue[Char.ToUpper(input[i + 1]) - '0']);
return Bytes;Hi,
I'm trying to share a calendar through ews managed api v.2 and using exchange 2013 version.
i'm preparing a shared calendar and providing values to extended properties .
Here comes the problem when i'm trying to send the sharing request(email message)
The following is code snippet.
public void ShareCalendar(Calendar calendar)
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.Credentials = new NetworkCredential("user1", "password", "domain");
service.Url = new Uri("https://sampleUrl/ews/exchange.asmx");
try
// Bind to the folder
//Folder folderStoreInfo;
//folderStoreInfo = Folder.Bind(service, calendar.ExchangeId);
//string EwsID = folderStoreInfo.Id.UniqueId;
string EwsID = calendar.FolderExchangeId;
// The value of folderidHex will be what we need to use for the FolderId in the xml file
AutodiscoverService autoDiscover = new AutodiscoverService(ExchangeVersion.Exchange2013);
autoDiscover.Credentials = new NetworkCredential("user1", "password", "domain");
autoDiscover.RedirectionUrlValidationCallback = RedirectionUrlValidationCallback;
Dictionary<string, string> userSettings = GetUserSettings(autoDiscover);
string folderidHex = GetConvertedEWSIDinHex(service, EwsID, "[email protected]");
string domainName = string.Empty;
string mailBoxServer = string.Empty;
string userName = string.Empty;
foreach (var item in userSettings)
switch (item.Key)
case "UserDN":
domainName = item.Value.ToString();
break;
case "InternalMailboxServer":
mailBoxServer = item.Value.ToString();
break;
case "UserDisplayName":
userName = item.Value.ToString();
break;
string entryId = GetIntiatorEntryID(domainName);
string mailboxId = GetInvitationMailboxId(mailBoxServer, domainName);
string sharedFilePath = CreateSharingMessageAttachment(folderidHex, userName, entryId, mailboxId, "user[email protected]", "calendar", calendar.FolderName);
// Create a new message
EmailMessage invitationRequest = new EmailMessage(service);
invitationRequest.Subject = "I'd like to share my calendar with you";
invitationRequest.Body = "Sent by Exchange Administrator on behalf of user";
//invitationRequest.Culture = "en-US";
invitationRequest.Sensitivity = Sensitivity.Normal;
// Set a sharing specific property on the message
invitationRequest.ItemClass = "IPM.Sharing"; /* Constant Required Value [MS-ProtocolSpec] */
byte[] byteEntryId = HexStringToByteArray(entryId);
// This is the Guid of the Sharing Provider in Exchange, and it's value does not change
Guid binSharingProviderGuid = new Guid("{AEF00600-0000-0000-C000-000000000046}");
// Even though I don't think setting this property is mandatory,
// it just seemed like the right thing to do and it works so I \
// ain't messin with it!
byte[] byteSharingProviderGuid = binSharingProviderGuid.ToByteArray();
string strPRBODYHTML = "<html dir=\"ltr\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\r\n<meta name=\"GENERATOR\"
content=\"MSHTML 8.00.7601.17514\">\r\n<style id=\"owaParaStyle\">P {\r\n MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px \r\n}\r\n</style>\r\n</head>\r\n<body fPStyle=\"1\" ocsi=\"0\">\r\n<tt>\r\n<pre>SharedByUserDisplayName
(SharedByUserSmtpAddress) has invited you to view his or her Microsoft Exchange Calendar.\r\n\r\nFor instructions on how to view shared folders on Exchange, see the following article:\r\n\r\nhttp://go.microsoft.com/fwlink/?LinkId=57561\r\n\r\n*~*~*~*~*~*~*~*~*~*\r\n\r\n</pre>\r\n</tt>\r\n<div>\r\n<div
style=\"direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;\">this is a test message</div>\r\n</div>\r\n</body>\r\n</html>\r\n";
string strBODY = @"
SharedByUserDisplayName (SharedByUserSmtpAddress) has invited you to view his or
her Microsoft Exchange Calendar.
For instructions on how to view shared folders on Exchange, see the
following article:
http://go.microsoft.com/fwlink/?LinkId=57561
*~*~*~*~*~*~*~*~*~*
test body
// Convert these to hex and binary equivelants to assign to their relevant
// extended properties
string hexPRBODYHTML = ConvertStringToHex(strPRBODYHTML);
byte[] binPRBODYHTML = HexStringToByteArray(hexPRBODYHTML);
Guid PropertySetSharing = Guid.Parse("00062040-0000-0000-C000-000000000046");//constant
Guid PropertySetInternetHeaders = Guid.Parse("00020386-0000-0000-C000-000000000046");//constant
ExtendedPropertyDefinition PidLidSharingProviderGuidProperty = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A01, MapiPropertyType.CLSID);
ExtendedPropertyDefinition ConversationIdProperty = new ExtendedPropertyDefinition(0x3013, MapiPropertyType.Binary);
// Sharing Properties (in order of reference according to protocol examples in: [MS-OXSHARE])
// Additional Property Constraints
// [MS-OXSHARE] 2.2.5.2
ExtendedPropertyDefinition PidTagMessageClass = new ExtendedPropertyDefinition(0x001A, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.5.1
//ExtendedPropertyDefinition PidNameContentClass = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "Content-Class", MapiPropertyType.String);
ExtendedPropertyDefinition PidNameContentClass = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "Content-class", MapiPropertyType.String);
// Common Message Object Properties
// [MS-OXSHARE] 2.2.1
ExtendedPropertyDefinition PidTagNormalizedSubject = new ExtendedPropertyDefinition(0x0E1D, MapiPropertyType.String);
// The PidTagSubjectPrefix is a zero-length string, so I do not set it
// ExtendedPropertyDefinition PidTagSubjectPrefix = new ExtendedPropertyDefinition(0x003D, MapiPropertyType.String);
// Sharing Object Message Properties
// [MS-OXSHARE] 2.2.2.12
ExtendedPropertyDefinition PidLidSharingProviderGuid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A01, MapiPropertyType.Binary);
// [MS-OXSHARE] 2.2.2.13
ExtendedPropertyDefinition PidNameXSharingProviderGuid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-GUID", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.14
ExtendedPropertyDefinition PidLidSharingProviderName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A02, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.15
ExtendedPropertyDefinition PidNameXSharingProviderName = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-Name", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.16
ExtendedPropertyDefinition PidLidSharingProviderUrl = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A03, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.17
ExtendedPropertyDefinition PidNameXSharingProviderUrl = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Provider-URL", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.5
ExtendedPropertyDefinition PidLidSharingFlavor = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A18, MapiPropertyType.Integer);
// [MS-OXSHARE] 2.2.2.6
ExtendedPropertyDefinition PidNameXSharingFlavor = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Flavor", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.1
ExtendedPropertyDefinition PidLidSharingCapabilities = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A17, MapiPropertyType.Integer);
// [MS-OXSHARE] 2.2.2.2
ExtendedPropertyDefinition PidNameXSharingCapabilities = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Capabilities", MapiPropertyType.String);
// Sections 2.3 and 2.4 are also zero-length strings, so I won't set those either
// [MS-OXSHARE] 2.2.2.3
// ExtendedPropertyDefinition PidLidSharingConfigurationUrl = new //ExtendedPropertyDefinition(PropertySetSharing, 0x8A24, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.4
//ExtendedPropertyDefinition PidNameXSharingConfigUrl = new //ExtendedPropertyDefinition(DefaultExtendedPropertySet.InternetHeaders, "X-Sharing-Config-Url", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.10
ExtendedPropertyDefinition PidLidSharingLocalType = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A14, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.11
ExtendedPropertyDefinition PidNameXSharingLocalType = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Local-Type", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.7
ExtendedPropertyDefinition PidLidSharingInitiatorEntryId = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A09, MapiPropertyType.Binary);
// [MS-OXSHARE] 2.2.2.8
ExtendedPropertyDefinition PidLidSharingInitiatorName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A07, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.2.9
ExtendedPropertyDefinition PidLidSharingInitiatorSMTP = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A08, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.1
ExtendedPropertyDefinition PidLidSharingRemoteName = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A05, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.2
ExtendedPropertyDefinition PidNameXSharingRemoteName = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Name", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.5
ExtendedPropertyDefinition PidLidSharingRemoteType = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A1D, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.6
ExtendedPropertyDefinition PidNameXSharingRemoteType = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Type", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.7
ExtendedPropertyDefinition PidLidSharingRemoteUid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A06, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.8
ExtendedPropertyDefinition PidNameXSharingRemoteUid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Uid", MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.3
ExtendedPropertyDefinition PidLidSharingRemoteStoreUid = new ExtendedPropertyDefinition(PropertySetSharing, 0x8A48, MapiPropertyType.String);
// [MS-OXSHARE] 2.2.3.4
ExtendedPropertyDefinition PidNameXSharingRemoteStoreUid = new ExtendedPropertyDefinition(PropertySetInternetHeaders, "X-Sharing-Remote-Store-Uid", MapiPropertyType.String);
//From troubleshooting I noticed I was missing
ExtendedPropertyDefinition PidTagPriority = new ExtendedPropertyDefinition(0x0026, MapiPropertyType.Integer);
ExtendedPropertyDefinition PidTagSensitivity = new ExtendedPropertyDefinition(0x0036, MapiPropertyType.Integer);
ExtendedPropertyDefinition PR_BODY_HTML = new ExtendedPropertyDefinition(0x1013, MapiPropertyType.Binary); //PR_BOD
ExtendedPropertyDefinition PR_BODY = new ExtendedPropertyDefinition(0x1000, MapiPropertyType.String);
ExtendedPropertyDefinition RecipientReassignmentProhibited = new ExtendedPropertyDefinition(0x002b, MapiPropertyType.Boolean);
// Section 2.2.1
invitationRequest.SetExtendedProperty(PidTagNormalizedSubject, "I'd like to share my calendar with you"); /* Constant Required Value [MS-OXSHARE] 2.2.1 */
//invitationRequest.SetExtendedProperty(PidTagSubjectPrefix, String.Empty); /* Constant Required Value [MS-OXSHARE] 2.2.1 */
// Section 2.2.2
invitationRequest.SetExtendedProperty(PidLidSharingCapabilities, 0x40220); /* value for Special Folders */
invitationRequest.SetExtendedProperty(PidNameXSharingCapabilities, "40220"); /* Test representation of SharingCapabilities value */
//invitationRequest.SetExtendedProperty(PidLidSharingConfigurationUrl, String.Empty); /* Zero-Length String [MS-OXSHARE] 2.2.2.3 */
//invitationRequest.SetExtendedProperty(PidNameXSharingConfigUrl, String.Empty); /* Zero-Length String [MS-OXSHARE] 2.2.2.4 */
invitationRequest.SetExtendedProperty(PidLidSharingFlavor, 0x20310); /* Indicates Invitation for a special folder [MS-OXSHARE] 2.2.2.5 */
invitationRequest.SetExtendedProperty(PidNameXSharingFlavor, "20310"); /* Text representation of SharingFlavor value [MS-OXSHARE] 2.2.2.6 */
invitationRequest.SetExtendedProperty(PidLidSharingInitiatorEntryId, byteEntryId); /* Value from the Initiator/EntryId value in the Sharing Message attachment .xml document */
invitationRequest.SetExtendedProperty(PidLidSharingInitiatorSMTP, "[email protected]"); /* Value from Initiator/Smtp Address in the Sharing message attachment .xml document */
invitationRequest.SetExtendedProperty(PidLidSharingInitiatorName, "User1"); /* Value from Initiator/Name Address in the Sharing message attachment .xml document */
invitationRequest.SetExtendedProperty(PidLidSharingLocalType, "IPF.Appointment"); /* MUST be set to PidTagContainerClass of folder to be shared */
invitationRequest.SetExtendedProperty(PidNameXSharingLocalType, "IPF.Appointment"); /* MUST be set to same value as PidLidSharingLocalType */
invitationRequest.SetExtendedProperty(PidLidSharingProviderGuid, byteSharingProviderGuid); /* Constant Required Value [MS-OXSHARE] 2.2.2.12 */
invitationRequest.SetExtendedProperty(PidNameXSharingProviderGuid, "AEF0060000000000C000000000000046"); /* Constant Required Value [MS-OXSHARE] 2.2.2.13 */
invitationRequest.SetExtendedProperty(PidLidSharingProviderName, "Microsoft Exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.14 */
invitationRequest.SetExtendedProperty(PidNameXSharingProviderName, "Microsoft Exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.15] */
invitationRequest.SetExtendedProperty(PidLidSharingProviderUrl, "http://www.microsoft.com/exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.16 */
invitationRequest.SetExtendedProperty(PidNameXSharingProviderUrl, "http://www.microsoft.com/exchange"); /* Constant Required Value [MS-OXSHARE] 2.2.2.17 */
// Section 2.2.3
invitationRequest.SetExtendedProperty(PidLidSharingRemoteName, calendar.FolderName); /* MUST be set to PidTagDisplayName of the folder being shared */
invitationRequest.SetExtendedProperty(PidNameXSharingRemoteName, calendar.FolderName); /* MUST be set to same value as PidLidSharingRemoteName */
invitationRequest.SetExtendedProperty(PidLidSharingRemoteStoreUid, mailboxId); /* Must be set to PidTagStoreEntryId of the folder being shared */
invitationRequest.SetExtendedProperty(PidNameXSharingRemoteStoreUid, mailboxId); /* MUST be set to same value as PidLidSharingRemoteStoreUid */
invitationRequest.SetExtendedProperty(PidLidSharingRemoteType, "IPF.Appointment"); /* Constant Required Value [MS-OXSHARE] 2.2.3.5 */
invitationRequest.SetExtendedProperty(PidNameXSharingRemoteType, "IPF.Appointment"); /* Constant Required Value [MS-OXSHARE] 2.2.3.6 */
invitationRequest.SetExtendedProperty(PidLidSharingRemoteUid, folderidHex); /* MUST be set to PidTagEntryId of folder being shared */
invitationRequest.SetExtendedProperty(PidNameXSharingRemoteUid, folderidHex); /* Must be set to same value as PidLidSharingRemoteUid */
// Section 2.2.5
invitationRequest.SetExtendedProperty(PidNameContentClass, "Sharing"); /* Constant Required Value [MS-ProtocolSpec] */
invitationRequest.SetExtendedProperty(PidTagMessageClass, "IPM.Sharing"); /* Constant Required Value [MS-ProtocolSpec] */
// ********* ADDITIONAL MAPPED PROPERTIES IM FINDING AS I TROUBLESHOOT ********************** //
invitationRequest.SetExtendedProperty(PidTagPriority, 0); /* From troubleshooting I'm just trying to match up values that were missing */
invitationRequest.SetExtendedProperty(PidTagSensitivity, 0); /* From troubleshooting as well */
invitationRequest.SetExtendedProperty(PR_BODY_HTML, binPRBODYHTML); /* From troubleshooting OWA error pointing to serializing HTML failing */
invitationRequest.SetExtendedProperty(PR_BODY, strBODY);
invitationRequest.SetExtendedProperty(RecipientReassignmentProhibited, true); /* Because it seemed like a good idea */
// Add a file attachment by using a stream
// We need to do the following in order to prevent 3 extra bytes from being prepended to the attachment
string sharMetadata = File.ReadAllText(sharedFilePath, Encoding.ASCII);
byte[] fileContents;
UTF8Encoding encoding = new System.Text.UTF8Encoding();
fileContents = encoding.GetBytes(sharMetadata);
//fileContents = File.ReadAllBytes(sharedFilePath);
//// fileContents is a Stream object that represents the content of the file to attach.
invitationRequest.Attachments.AddFileAttachment("sharing_metadata.xml", fileContents);
////invitationRequest.Attachments.AddFileAttachment(sharedFilePath);
//// This is where we set those "special" headers and other pertinent
//// information I noted in Part 1 of this series...
//Attachment thisAttachment = invitationRequest.Attachments[0];
//thisAttachment.ContentType = "application/x-sharing-metadata-xml";
//thisAttachment.Name = "sharing_metadata.xml";
//thisAttachment.IsInline = false;
// Add recipient info and send message
invitationRequest.ToRecipients.Add(new EmailAddress() { Address = "[email protected]" });
invitationRequest.SendAndSaveCopy();
// I always end my methods by returning the EWS
// impersonated user to null to clean up
service.ImpersonatedUserId = null;
catch (Exception ex)
public String GetConvertedEWSIDinHex(ExchangeService esb, String sID, String strSMTPAdd)
// Create a request to convert identifiers.
AlternateId objAltID = new AlternateId();
objAltID.Format = IdFormat.EwsId;
objAltID.Mailbox = strSMTPAdd;
objAltID.UniqueId = sID;
//Convert PR_ENTRYID identifier format to an EWS identifier.
AlternateIdBase objAltIDBase = esb.ConvertId(objAltID, IdFormat.HexEntryId);
AlternateId objAltIDResp = (AlternateId)objAltIDBase;
return objAltIDResp.UniqueId.ToString();
public String GetInvitationMailboxId(string mailBoxServer, string domainName)
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "[email protected]");
// Generate The Store Entry Id for the impersonated user
StringBuilder MailboxIDPointer = new StringBuilder();
string fqdn = mailBoxServer;
string legacyDN = domainName;
MailboxIDPointer.Append("00000000"); /* Flags */
MailboxIDPointer.Append("38A1BB1005E5101AA1BB08002B2A56C2"); /* ProviderUID */
MailboxIDPointer.Append("00"); /* Version */
MailboxIDPointer.Append("00"); /* Flag */
MailboxIDPointer.Append("454D534D44422E444C4C00000000"); /* DLLFileName */
MailboxIDPointer.Append("00000000"); /* Wrapped Flags */
MailboxIDPointer.Append("1B55FA20AA6611CD9BC800AA002FC45A"); /* WrappedProvider UID (Mailbox Store Object) */
MailboxIDPointer.Append("0C000000"); /* Wrapped Type (Mailbox Store) */
MailboxIDPointer.Append(ConvertStringToHex(fqdn)); /* ServerShortname (FQDN) */
MailboxIDPointer.Append("00"); /* termination bit */
MailboxIDPointer.Append(ConvertStringToHex(legacyDN)); /* Returns the userDN of the impersonated user */
MailboxIDPointer.Append("00"); /* terminator bit */
service.ImpersonatedUserId = null;
return MailboxIDPointer.ToString();
static bool RedirectionUrlValidationCallback(String redirectionUrl)
bool redirectionValidated = false;
if (redirectionUrl.Equals("https://SampleUrl/autodiscover/autodiscover.xml"))
redirectionValidated = true;
return redirectionValidated;
public String GetIntiatorEntryID(string domainName)
String result = String.Empty;
//// Bind to EWS
//ExchangeService service = ExchangeConnection.ExchangeService();
//service.ImpersonatedUserId =
//new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "[email protected]");
//// Get LegacyDN Using the function above this one
string sharedByLegacyDN = domainName;
// A conversion function from earlier
string legacyDNinHex = ConvertStringToHex(sharedByLegacyDN);
StringBuilder addBookEntryId = new StringBuilder();
addBookEntryId.Append("00000000"); /* Flags */
addBookEntryId.Append("DCA740C8C042101AB4B908002B2FE182"); /* ProviderUID */
addBookEntryId.Append("01000000"); /* Version */
addBookEntryId.Append("00000000"); /* Type - 00 00 00 00 = Local Mail User */
addBookEntryId.Append(legacyDNinHex); /* Returns the userDN of the impersonated user */
addBookEntryId.Append("00"); /* terminator bit */
result = addBookEntryId.ToString();
//service.ImpersonatedUserId = null;
return result;
public string ConvertStringToHex(string input)
// Take our input and break it into an array
char[] arrInput = input.ToCharArray();
String result = String.Empty;
// For each set of characters
foreach (char element in arrInput)
if (String.IsNullOrEmpty(result))
result = String.Format("{0:X2}", Convert.ToUInt16(element)).ToString();
else
result += String.Format("{0:X2}", Convert.ToUInt16(element)).ToString();
return result.ToString();
public string CreateSharingMessageAttachment(string folderid, string userSharing, string userSharingEntryID, string invitationMailboxID, string userSharedTo, string dataType, string calendarName)
XmlDocument sharedMetadataXML = new XmlDocument();
string sharedMetaDataFilePath = string.Empty;
try
// Create a String that contains our new sharing_metadata.xml file
StringBuilder metadataString = new StringBuilder("<?xml version=\"1.0\"?>");
metadataString.Append("<SharingMessage xmlns=\"http://schemas.microsoft.com/sharing/2008\">");
metadataString.Append("<DataType>" + dataType + "</DataType>");
metadataString.Append("<Initiator>");
metadataString.Append("<Name>" + userSharing + "</Name>");
metadataString.Append("<SmtpAddress>" + "[email protected]" + "</SmtpAddress><EntryId>" + userSharingEntryID.Trim());
metadataString.Append("</EntryId>");
metadataString.Append("</Initiator>");
metadataString.Append("<Invitation>");
metadataString.Append("<Title>" + calendarName + "</Title>");
metadataString.Append("<Providers>");
metadataString.Append("<Provider Type=\"ms-exchange-internal\" TargetRecipients=\"" + userSharedTo + "\">");
metadataString.Append("<FolderId xmlns=\"http://schemas.microsoft.com/exchange/sharing/2008\">");
metadataString.Append(folderid);
metadataString.Append("</FolderId>");
metadataString.Append("<MailboxId xmlns=\"http://schemas.microsoft.com/exchange/sharing/2008\">");
metadataString.Append(invitationMailboxID);
metadataString.Append("</MailboxId>");
metadataString.Append("</Provider>");
metadataString.Append("</Providers>");
metadataString.Append("</Invitation>");
metadataString.Append("</SharingMessage>");
sharedMetadataXML.LoadXml(metadataString.ToString());
string tempPath = System.IO.Path.GetTempPath();
sharedMetaDataFilePath = tempPath + "sharing_metadata.xml";
sharedMetadataXML.Save(sharedMetaDataFilePath);
catch (Exception eg)
throw eg;
return sharedMetaDataFilePath;
public Dictionary<string, string> GetUserSettings(AutodiscoverService autodiscoverService)
GetUserSettingsResponse userresponse = autodiscoverService.GetUserSettings(
"[email protected]",
UserSettingName.UserDisplayName,
UserSettingName.InternalMailboxServerDN,
UserSettingName.UserDN
Dictionary<string, string> myUserSettings = new Dictionary<string, string>();
foreach (KeyValuePair<UserSettingName, Object> usersetting in userresponse.Settings)
if (usersetting.Key.ToString() == "InternalMailboxServerDN")
int lastIndexOfEqual = usersetting.Value.ToString().LastIndexOf("=");
string subString = usersetting.Value.ToString().Substring(lastIndexOfEqual + 1);
string value = subString;
myUserSettings.Add("InternalMailboxServer", value.ToString());
if (usersetting.Key.ToString() == "UserDisplayName")
string[] arrResult = usersetting.Value.ToString().Split('.');
myUserSettings.Add("UserDisplayName", arrResult[0].ToString());
if (usersetting.Key.ToString() == "UserDN")
string[] arrResult = usersetting.Value.ToString().Split('.');
myUserSettings.Add("UserDN", arrResult[0].ToString());
return myUserSettings;
private static byte[] HexStringToByteArray(string input)
byte[] Bytes;
int ByteLength;
string HexValue = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9|||||||\xA\xB\xC\xD\xE\xF";
ByteLength = input.Length / 2;
Bytes = new byte[ByteLength];
for (int x = 0, i = 0; i < input.Length; i += 2, x += 1)
Bytes[x] = (byte)(HexValue[Char.ToUpper(input[i + 0]) - '0'] << 4);
Bytes[x] |= (byte)(HexValue[Char.ToUpper(input[i + 1]) - '0']);
return Bytes;
am i missing anything
any help is appreciated
Thanks in advance -
How to get list of Users under an Auth Group (for executable Programs)?
Hi experts. I have a requirement to get a list of all users under a particular Auth Group for Program Objects.
Goal of this requirement is to identify the users allowed to use/access a program - we're doing some sort of Program Inventory and we'd like to identify the users per program, via the Auth Group.
So question is: Which tables hold data about Program <-> Auth Group <-> Users, and how are they linked?
I know this is Basis/Security stuff, but I was thinking of developing a report program to output the information needed.
Thanks in advance.
Edited by: George Esquerra on Nov 17, 2011 10:24 AMThis is available in the standard via tx SUIM - user - users by complex selection criteria - by authorization values.
If you enter auth object = S_PROGRAM and value = auth group, you will get the list of users.
You can analyse how this program finds the information and incorporate it into your own logic.
Thomas -
Hi,
I want to fetch the list of users who all are having full access to the sharepoint list using client object model with .Net
Please let me know if any property for the user object or any other way to get it.
Thanks in advance.Here you are complete code i created from some years it lists all groups and users, you can just add a check in the permissions loop to see if it is equal to Full Control.
Private void GetData(object obj)
MyArgs args = obj as MyArgs;
try
if (args == null)
return; // called without parameters or invalid type
using (ClientContext clientContext = new ClientContext(args.URL))
// clientContext.AuthenticationMode = ClientAuthenticationMode.;
NetworkCredential credentials = new NetworkCredential(args.UserName, args.Password, args.Domain);
clientContext.Credentials = credentials;
RoleAssignmentCollection roles = clientContext.Web.RoleAssignments;
ListViewItem lvi;
ListViewItem.ListViewSubItem lvsi;
ListViewItem lvigroup;
ListViewItem.ListViewSubItem lvsigroup;
clientContext.Load(roles);
clientContext.ExecuteQuery();
foreach (RoleAssignment orole in roles)
clientContext.Load(orole.Member);
clientContext.ExecuteQuery();
//name
//MessageBox.Show(orole.Member.LoginName);
lvi = new ListViewItem();
lvi.Text = orole.Member.LoginName;
lvsi = new ListViewItem.ListViewSubItem();
lvsi.Text = orole.Member.PrincipalType.ToString();
lvi.SubItems.Add(lvsi);
//get the type group or user
// MessageBox.Show(orole.Member.PrincipalType.ToString());
if (orole.Member.PrincipalType.ToString() == "SharePointGroup")
lvigroup = new ListViewItem();
lvigroup.Text = orole.Member.LoginName;
// args.GroupsList.Items.Add(lvigroup);
DoUpdate1(lvigroup);
Group group = clientContext.Web.SiteGroups.GetById(orole.Member.Id);
UserCollection collUser = group.Users;
clientContext.Load(collUser);
clientContext.ExecuteQuery();
foreach (User oUser in collUser)
lvigroup = new ListViewItem();
lvigroup.Text = "";
lvsigroup = new ListViewItem.ListViewSubItem();
lvsigroup.Text = oUser.LoginName;
lvigroup.SubItems.Add(lvsigroup);
//args.GroupsList.Items.Add(lvigroup);
DoUpdate1(lvigroup);
// MessageBox.Show(oUser.LoginName);
RoleDefinitionBindingCollection roleDefsbindings = null;
roleDefsbindings = orole.RoleDefinitionBindings;
clientContext.Load(roleDefsbindings);
clientContext.ExecuteQuery();
//permission level
lvsi = new ListViewItem.ListViewSubItem();
string permissionsstr = string.Empty;
for (int i = 0; i < roleDefsbindings.Count; i++)
if (i == roleDefsbindings.Count - 1)
permissionsstr = permissionsstr += roleDefsbindings[i].Name;
else
permissionsstr = permissionsstr += roleDefsbindings[i].Name + ", ";
lvsi.Text = permissionsstr;
lvi.SubItems.Add(lvsi);
// args.PermissionsList.Items.Add(lvi);
DoUpdate2(lvi);
catch (Exception ex)
MessageBox.Show(ex.Message);
finally
DoUpdate3();
Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation -
How to get list of users who have access to a SAP module
Hi,
We are developing a tool in Java where we will pull the data from various modules in SAP (like Purchase order, Invoice etc). Lets take Purchase Order Module as example. I can get the data using BAPIs (like BAPI_PO_GETDETAIL).
However to implement Authorization, I also want the list of users/groups that have access to Purchase order module. Is this possible? Or can we get the ACL information from the tables in database like EKKO for Purchase order?
I have tried searching for solution but couldn't find any. Please suggest if there is some standard way by which we can pull the ACL information via Java, or if this can be achieved by some custom RFCs.
Thanks,
AnuragAnurag,
The best way is to wirte a RFC Function Module (It will fetch the roles of the user from agr_users table) which will take user id as import paramter and will give you assigned roles.
Please let me know if you still need any further information.
Thanks,
Hamendra -
How to get list of users with access of MM01 (create & change)
Hi all,
i have to take out list of user having access for MM01 (create material), when i use SUIM to get the list it shows all the list of users including the users with DISPLAY & CHANGE, but i want only those users who had the access of CREATE & CHANGE.
please help out me, its very urgent.
Thanks & Regards
Syed..Hi Syed,
You can try to get it from S_BCE_68001398. Key in the required transaction code.
Thanks and Regards
Points reward is much appreciated -
How to get list of users assinged the same product catagory
Hi All ,
we have a requirement in which we need to get the list of users who are assigned the same product category.
ie if we give the prod category 14000000 then we need the list of users assigned the 14000000 prod category.
is any FM available.
please help.
Regards
Channappa SajjanarHi Chinnappa,
1) You can create a table query for tables HRT1222 and HRP1222 to get the org Id or Position Id assigned for the product category.
Then use FM BBP_OM_STRUC_GET_USER_FROM_POS to get the list of users for that org ID.
2) or if you want to check list of prod categories linked to user ID, then use FM BBP_READ_ATTRIBUTES
rgds,
Ravi -
How to get list of users using IN OIM
Experts,
Is it possible to get the list of users who have logged into OIM in past (for example last six months)? as not all people in my organization uses OIM.
Please suggest if OIM(version 9.1.02) has any such functionality or if it is possible to get it from OIM database.
Thanks,
S MOIM will not store last logon date & time. So this is not possible. If you have access manager integrated environment, then OID will have last logon date & time. in such environment, from OID, you can get these details.
-
How to get timesheet information in a javascript (Project Server 2013)
Hi all,
In Project Server 2013, I'm trying to customize the Timesheet ribbon. This far, I've been able to add a new button and tie an event to it. All is working well. This is all done using elements.xml and a javascripts.
Now the problem is that I want to get some informations about the timesheet (the Guid for example) and, for now, I've got no success. I know that there is an object called PS.TimeSheet, but when I try to use some PS.TimeSheet's methods I get an error.
Note that i'm in the page http://servername/pwa/timesheet.aspx (there is not Guid in the address) and all the treatments should be done in the javascript (no call to another aspx page)
Thanks !Finally, I've found the solution.
My goal was to add a button in the timesheet ribbon to launch a special report showing some data about the timesheet. The report has the timesheet Guid as parameter.
To customize the Sharepoint ribbon, you have to do it via an xml file and a javascript (a lot of explanation is available in the internet that explains how to do it). So I had to call a function in the javascript to launch the report (which is a SSRS report).
When you are in a javascript you have access to many global variables. When the timesheet.aspx is displayed, there is a global variable called "timesheetComponent".
Using this variable we can call the method :
timesheetComponent.m_consumedApi.get_Impl()
to get an implementation of the current timesheet. This implementation has an attibute that has a lot of nice stuff about the current user and the current time sheet. This attribute is
_headerInfo
_headerInfo is a structure that includes tsUid which contains the timesheet Guid I was looking for.
Finally, the function attached to the button goes like this :
function _LaunchReport() {
var tsUId;
var rptPath;
var tsImpl = timesheetComponent.m_consumedApi.get_Impl();
try
if (CONST_REPORT_PATH == null || CONST_REPORT_PATH == "" ) {
alert("Constant CONST_REPORT_PATH is not defined")
else {
tsUId = tsImpl._headerInfo.tsUid;
rptPath = CONST_REPORT_PATH + 'TimesheetDetails&rs:Command=Render&rc:Parameters=false&TimesheetUID=' + tsUId;
window.open(rptPath);
catch (Err) {
alert(Err)
CONST_REPORT_PATH is the path to SSRS defined elsewhere
I hope this will help some other poeple ! -
How to get list of user from Role in workflow
Hi,
I want to send notification to all user belongs to a certain role in OIM.
How can i do this?
My req:- User put's request for provisioning. now we have to send notification to all the approver about the request.
I know i have to use BPEL for sending notification.
But can some one let me know how can i get email id of approver in BPEL.Make a groups in OIM and assign all the approves for that role in that group.
Select this group as an approve in SOA composite.
Now when ever any approval request is send for provisioning it will go to all the members of that group.
Maybe you are looking for
-
Home directories not being created
Hi, I am having trouble creating home directories for users on my OSX Server Tiger 10.4.4 running on a mac mini. Home directoried do not seem to be created for users on my Open Directory. I have configured my server to be an Open Directory master. I
-
How would I unit test database logic?
I am still having a issue getting over a small issue when it comes to TDD. I need a method that will get a certain record set of filtered data from the data layer (linq2SQL). Please note that i am using the linq generated classes from that are genera
-
I just finished rough editing 1920 X 1080 video footage. I want to try to burn the 70 GB file to a dvd to see if there are any issues before I go further with music and special effects. I would rather do it with Toast, but it will only take 99 clips
-
HI Guys, I have a uniques requirement where i need to hvae only one qty per delivery against the 'N' open quantity in sales order, we use a batch program to create a delivery. I would like to know is their any configuration where we can set to make
-
Avidemux audio sync problem with MPEG-2 - alt. way to cut mpeg-2
I have a PVR-250 and when I load up an MPEG-2 file that it generated in Avdimux, the audio/video is out of sync (before I make any edits). My goal is simply to cut out commercials in the file, nothing else. When I play it in any other viewer (vlc, m