InfiniTec - Henning Krauses Blog

Don't adjust your mind - it's reality that is malfunctioning

InfiniTec.Exchange

This article has been superseeded by this article.

Introduction

This library is the successor to my WebDAVLayer. In fact, the WebDAVLayer was never meant to be released to the public and had no documentation. As such, the library was very difficult to use.

Another problem was the lack of asynchronous methods. Because of this, the library did not scale well.

This new release is a complete rewrite of that library and provides a very simple set of classes. Additionally, everything is documented and an example application is included.

Why only .NET 2.0?

A recent question I got was whether I would release a version of this library which could be compiled with .NET 1.1. The reason, why I will not do this is because of the heavy usage of .NET 2.0 features, like generics and iterators. It would be a major rewrite of the library, and for all future releases I would have to maintain two branches. Since I do this in my spare time, that would be to much work.

Status

This is an early beta version. You should expect that some features still do not work as expected.

Many features are not yet implemented. This includes support for the WebDAV SUBSCRIBE methods, support for batch operations (BMOVE and BCOPY), recovering of deleted items and discovery mechanisms.

Be extremely careful when settings permission. Do set permissions with this version of the library on on a production server, because it may corrupt the security descriptor on the folder. If you accidently messed up a security descriptor, you can use the PfDavAdminTool to correct those descriptors.

Structure

The main classes are displayed below:


InfiniTec.Exchange class diagram (click to enlarge)

The entry point is the Connection class. This class specifies the context information for the WebDAV requests. To create a new connection, this code can be used:

    1 Connection connection = newConnection();

    2 

    3 connection.ConnectionProtocol = ConnectionProtocol.Http;

    4 

    5 connection.Server = "myserver";

    6 connection.Credential.Username = "administrator";

    7 connection.Credential.Password = "password";

    8 connection.Credential.AuthenticationType = AuthenticationType.Basic;

This connection can now be used to instantiate one of the other classes:

    1 Item item = newItem("public/my folder", connection);

    2 item.Refresh();

    3 

    4 bool isHidden = item.Properties.GetProperty<bool>(Namespaces.Dav, "ishidden").Value;

All operations are available in a synchronous version as well as an asynchronous version. The above refresh operation can also be called asynchronously:

    1 Item item = newItem("public/my folder", connection);

    2 item.RefreshCompleted += item_RefreshCompleted;

    3 item.RefreshProgressChanged += item_RefreshProgressChanged;

    4 item.RefreshAsync();

During the refresh operation, the ProgressChanged event is called multiple times. When the operation finishes, the Completed event is called.

Managing security on items

The Folder.GetSecurity() and Item.GetSecurity() methods provide access to the security descriptors on Exchange folder and items. Unlike Outlook, this package allows permissions to be set on every item, not only on folders.

The basic classes for manipulation of security descriptors are displayed in this class diagram:


Classdiagram of Exchange security descriptors

The GetAccessControlEntries() method of either the FolderSecurity or ItemSecurity class returns a collection of ItemAce (or FolderAce respectively), which look like this:


Class diagram of the security system (click to enlarge)

Three different levels of access masks are used:

  • The AccessRole define the eight standard roles also defined by Outlook. Additionally, the FolderVisible role is defined. This enumeration is only defined on folder objects.
  • The AccessMasks enumeration represents the basic access operations used in Outlook. These access masks applies both to items and folders.
  • The FolderAccessMasks and ItemAccessMasks define the low-level permissions on folders and items.

To set permission on folder and items, use the SetSecurity() method of the ItemAce or FolderAce class. Be extremely careful if you want to set the ItemAccessMasks or FolderAccessMasks directly. The corresponding methods do have the Dangerous prefix for a reason!

ChangeLog

Version 0.93 - 07-23-06

  • Fixed several issues with FormBased authentication
  • New FormbasedAuthenticationRequiredException, which is thrown when an attempt is made to access an item which requires form based authentication.
  • Moved the DangerousSetAccess method from the ExchangeSecurity to the ItemSecurity
  • Added a DangererousSetAccess method to the FolderSecurity class.
  • Fixed an error in the ItemSecurity.SetAccess(AccessMasks) and FolderSecurity.SetAccess(AccessMasks) method (NullReferenceException).
  • All methods calling event handler (OnRefreshCompleted, etc.) are now "protected virtual"
  • Added Attachment handling (via the Item.Attachments property). Attachments can be enumerated, added and removed.
  • All EventHandler<ProgressChangedEventArgs<RequestStatus>> have been replaced with a ProgressChangedEventHandler<RequestStatus>
  • The RefreshScope has been removed
  • The RefreshStatus has been removed
  • The Refresh operations of the Item class do not have a parameter any longer
  • RequestStatus.BeginningFormBasedAuthentication renamed to RequestStatus.PerformingFormBasedAuthentication.
  • The Item class now has a GetContent/GetContentAsync and a SetContent/SetContentAsync methods operation which allow downloading/setting the the MIME content of the item.

Version 0.92 - 05-21-06

  • Fixed a bug in the PropertyCollection.Contains method
  • Added several TryGetProperty and TryGetMultiValuedProperty methods to the PropertyValueCollection
  • Added GetSecurity() methods to the Item and Folder class, which provides access to the security descriptor of that item
  • Added classes for manipulation of the security descriptors of an item

Version 0.91 - 05-17-06

  • Properties are now strongly typed. Single-Valued properties are of type Property<T> and multi valued properties are of type MultiValuedProperty<T>
  • Removed the IsMultiValued and Type properties from the Property class. On a refresh operation, the HTTP result is now reflected in each property.
  • The Properties collection now contains properties which could not be successfully loaded. Those properties are of type Property and have a Property.Status.StatusCode != HttpStatusCode.Ok.
  • When a property is accessed via the Item.Properties indexer or any other of the GetProperty<T> or GetMultiValuedProperty<T> methods, an exception is thrown, whenever the Property.Status.StatusCode != HttpStatusCode.Ok.

Version 0.9 - 05-15-06

  • Initial release

Downloads

InfiniTec.Exchange_Release.zip (129,280 Bytes)
Version 0.93 release compile including debug symbol, signed with the InfiniTec private key
Documentation.zip (251,173 Bytes)
Documentation as CHM file
InfiniTec.Exchange_Source.zip (91,769 Bytes)
Source code version 0.93
ExampleApplication.zip (66,862 Bytes)
Example application

Technorati:

Posted by Henning Krause on Sunday, May 14, 2006 12:00 AM, last modified on Monday, November 29, 2010 7:16 PM
Permalink | Post RSSRSS comment feed