InfiniTec - Henning Krauses Blog

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

Exchange library updated again

Here is another update on the InfiniTec.Exchange library. Among a few bug fixes, there are several new classes which simplify access to the Exchange store. Here is a class diagram of those classes:

Class diagram of Active Directory integration (click to enlarge)

To get the address of a users mailbox, you can now use the User class, which exposes a property named Mailbox. Be sure to call the Refresh or RefreshAsync method before accessing it.

To get a user object, you can either traverse the address lists defined in the Exchange organization by using the AddressListManager class.

Another way is to use the UserResolver which uses "ambiguous name resolution" and "search by initials" to find users: Specifying a Filter of jd will return John Doe. Specifiy john will do return all users with the name joe. This is essentially, what Outlook does when you execute the "Resolve Name" function. But in this case, the users contact folder is not searched.

Permissions needed

The problem with resolving the mailbox url or enumerating the address lists is that these operations require access to the Exchange configuration in the Active Directory. This data is stored under CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=primary_domain. By default, normal users do not have access to this data.

Downloads (386,492 Bytes)
Release Build of version 0.98 (301,731 Bytes)
Source code of version 0.98 (768,932 Bytes)
Documentation (279,372 Bytes)
Example application


Posted by Henning Krause on Sunday, January 7, 2007 12:00 AM, last modified on Sunday, January 7, 2007 12:00 PM
Permalink | Post RSSRSS comment feed

Exchange Library 0.97

It's time for a new update to my Exchange access library. Again, several breaking changes, as the number of classes grow. So, here is the new class diagram:

(click to enlarge)

And there are a few more classes worth writing about: The Searcher<ItemType> is a Searcher class which returns MessageItems, CalendarItems and so on. Next, the Folder<ItemType> implements the folder functionality for the same classes. And finally, the Mailbox class provides access to the wellknown folders like Calendar, Inbox, Outbox and so on - language independent. So, here is the diagram for these classes:

If you have comments or if you found an error, please drop me a note.

Changelog for this version

  • The Item class now has most of the methods from the SimpleItem class: Delete, Copy, Move
  • The host of the url passed to the an Item or Folder class now checks the IP addresses of the specified hostname instead of the literal hostname. If an IP address is specified as a server, no DNS resolution is attempted.
  • New Searcher<ItemType> class. Allows to directly search for tasks, appointments, calendaritems..
  • New Folder<ItemType> class. 
  • New Mailbox class which provides language-independent access to the wellknown folders like inbox, outbox, tasks...
  • Renamed Item to SimpleItem
  • Renamed TypedItemBase to Item
  • Renamed Task to TaskItem
  • Renamed Contact to ContactItem
  • Renamed Message to MessageItem
  • Item is no longer abstract
  • Item and its descendents now all have a parameterless constructor
  • Fixed a bug in the ContactItem class which prevented a successful save operation
  • Fixed several bugs in the security logic.

Downloads (253,065 Bytes)
Binaries for version 0.97, strong-named (501,698 Bytes)
Example application for version 0.97 (855,323 Bytes)
Source files for version 0.97 (667,023 Bytes)
Documentation for version 0.97.


Posted by Henning Krause on Tuesday, January 2, 2007 12:00 AM, last modified on Tuesday, January 2, 2007 12:00 PM
Permalink | Post RSSRSS comment feed

Two-way databinding with ASP.NET struggles with DateTime conversion

When you create a website with ASP.NET 2.0 and use the two-way databinding with an object datasource, you might have come accross this error:

Cannot convert value of parameter 'Created' from 'System.String' to 'System.DateTime'

This happens when you bind a data field with a DateTime datatype to a textbox, either with the BoundField method or with the <%# Bind("...") %> keyword.

One additional requirement for this error to happen is that the user local is set to non-english (respectively the invariant culture).

Digging deeper into the ObjectDataSourceView with Reflector, I found the cause for this strange behavior: The Bind-keyword or the BoundField class formats the string according to a format string. This, by default that a DateTime is displayed in german as follows:

29.11.2006 09:12:24 (e.g. dd.MM.yyyy hh:mm:ss).

When ASP.NET attempts to write back the changes made by the user, it reads the value from the textbox and tries to convert it from a string to a DateTime object.  It does this by retrieving the TypeConverter responsible for the DateTime class and calls typeConverter.ConvertFromInvariantString(). This obviously fails with a non-english string and produces the error seen above.

The default.aspx file in the attached Visual Studio Solution shows this error.


The workaround I'm using for this issue is to attach an Item_Updating event to the data control (DetailsView, FormView, etc). This event then converts the dataformat to an invariant datetime string:

    1 protectedvoid DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)

    2 {

    3     e.NewValues["Created"] = DateTime.Parse((string) e.NewValues["Created"]).ToString(CultureInfo.InvariantCulture);

    4 }

The solution.aspx file implements this workaround.

Downloads (18,427 Bytes)
Example application which demonstrates the described problem and workaround


Posted by Henning Krause on Wednesday, November 29, 2006 12:00 AM, last modified on Wednesday, November 29, 2006 12:00 PM
Permalink | Post RSSRSS comment feed

Using the GenuineChannels SharedMemory Channel with Windows Vista

If you are using the shared memory remoting channel from GenuineChannels under Vista, you can quickly become a victim of a new security feature of Windows Vista: Global objects (a Mutex in the global namespace, for example) can only be created in session 0 - and with Vista, only services run in session 0.

The GenuineChannels SharedMemoryChannel creates a global mutex by default, and will fail with with this error message:

Can not create or open a memory file mapping. Error code: 2. Use the Visual C++ Error Lookup utility to see the text of the error message.

Consider the following code for the initialization of the remoting infrastructure:

    1 publicvoid InitializeRemoting(string name, string address)

    2 {

    3     Hashtable properties;

    4     GenuineSharedMemoryChannel channel;


    6     properties = newHashtable();


    8     properties = newHashtable();

    9     properties["listen"] = address;

   10     properties["name"] = name;

   11     properties["priority"] = 100;


   13     channel = newGenuineSharedMemoryChannel(properties, null, null)

   14     ChannelServices.RegisterChannel(channel);

   15 }

To force the channel to create session-local objects only, insert the following line at line 12:

   12     properties["smsessionlocal"] = true;



Posted by Henning Krause on Wednesday, November 1, 2006 12:00 AM, last modified on Wednesday, November 1, 2006 12:00 PM
Permalink | Post RSSRSS comment feed

Security class library updated

Several changes in this release… so a new class diagram is advised:

Class diagram of the InfiniTec.Security 1.4 package (click to enlarge)

Breaking change is the renaming of the *SecurityContext* classes to *ImpersonationScope* classes. Additionally, a new base class has been introduced, the ImpersonationScope class, which essentially takes a username/password combination and does the impersonation.

Also new is the privilege handling: Privileges held by a WindowsIdentity can be enumerated, activated and permanently removed from the token.

Finally, the IdentityResolver can be used for two things:

  1. Translate a SID to an NT account name and vice versa on a remote machine.
  2. Identify the type of an account (User, group, computer, alias,…)

Change log

  • The *SecurityContext* classes have been renamed to *ImpersonationScope*
  • The SecurityContext class has been renamed to CallbackImpersonationScope
  • New ImpersonationScope class, which accepts a username/password combination
  • The AcquireCredentialCallbackEventHandler class has been removed in favor of the EventHandler<AcquireCredentialEventArgs> class
  • Privilege Management: The Privileges and Privilege classes allows the manipulation of privileges held by a WindowsIdentity.
  • New IdentityResolver. Basically, the same functionality as IdentityReference.Translate(). However, a remote computer can be used for the translation process. Additionally, the type of the account type (user, group, computer, etc) is returned

Downloads (51,460 Bytes)
Source code of the 1.4 version (48,179 Bytes)
Release build with debug symbols. Signed with the InfiniTec private key (240,624 Bytes)
Documentation of this release as CHM file.


Posted by Henning Krause on Sunday, October 29, 2006 12:00 AM, last modified on Sunday, October 29, 2006 11:00 AM
Permalink | Post RSSRSS comment feed

New version of the Exchange class library

This is a bug-fix release.


  • Fixed a bug in the Security logic. It is now possible to set permissions on groups (security and distribution) without destroying the security descriptor
  • Fixed a bug with MultiValued properties
  • Fixed a bug with the Duedate property of tasks
  • Fixed a bug which prevented the manipulation of properties which names started with 0x
  • Removed the set part of the Task.IsComplete property. This has been replaced by a SetComplete(DateTime) method.
  • Added an IconIndex enumeration and changed the data type of the TypedItemBase.IconIndex from int? to IconIndex?
  • Fixed a bug in the Attachment class

Downloads (223,936 Bytes)
InfiniTec.Exchange 0.96 Source code (239,684 Bytes)
InfiniTec.Exchange 0.96 binaries, signed with the InfiniTec private key. Release-Build with debug symbols (818,848 Bytes)
Documentation as CHM file (453,545 Bytes)
Example application


Posted by Henning Krause on Sunday, October 29, 2006 12:00 AM, last modified on Sunday, October 29, 2006 11:00 AM
Permalink | Post RSSRSS comment feed

How to read the Internet Message Header from an email via WebDAV

Ever wanted to read the internet message header of an email via WebDAV?

Internet message headers in Outlook (click to enlarge)

This property is available via the property


Posted by Henning Krause on Monday, October 2, 2006 12:00 AM, last modified on Sunday, October 29, 2006 11:00 AM
Permalink | Post RSSRSS comment feed

Formbased authentication and Exchange 2007

If you have tried to access an Exchange 2007 mailbox or public folder via WebDAV with Formbased Authentication enabled, you might have found out, that it does not work in the current bet: Although you get the necessary cookies, the next request fails with a 440-Login Timeout.

This happens because of the way the Exchange virtual directories are set up - the /Exchange virtual directory runs in another application pool than the /exchweb virtual. This results in different encryption keys being used for the encoding of the cookies.

To work around this, ensure that /OWA and the /Exchange and /Public virtual folders are running in the same application domain.

However, these changes are unsupported and may break uninstallation of Exchange 2007.

This issue has been fixed in post-beta 2 releases.

Btw, the Exchange version I have tested this on is 8.0.605.16.


Posted by Henning Krause on Thursday, September 21, 2006 12:00 AM, last modified on Monday, November 29, 2010 8:59 PM
Permalink | Post RSSRSS comment feed

Another update for the DirectoryServices library

This update fixes some serious bugs and adds the ability to save changes made to an item back to the directory server:

    1 ActiveDirectoryUser user;


    3 using (Connection connection = newConnection("contoso.local", DirectoryIdentifierType.Server, false, newNetworkCredential("administrator", "password", "contoso"), AuthType.Basic))

    4 {

    5     user = newActiveDirectoryUser("CN=Alice, CN=Users, DC=contoso, DC=local", connection);

    6     user.Refresh();


    8     user.Description = "The quick brown fox jumps over the lazy dog";


   10     user.Save(false);

   11 }

The Save and SaveAsync methods both accept one boolean parameter. If set to true, the save operation will return before the changes have been committed to disk by the directory server (known as lazy commit). This improves performance, but increases the likelihood of data loss.


Changes made from version 1.0 to version 1.1:

  • Added a static Open method to the ActiveDirectoryPrinicipal object, which either returns an ActiveDirectoryUser or an ActiveDirectoryGroup object

  • Added the ability to save changes back to server.

  • Fixed a bug with integrated authentication when using the Translator class

  • Fixed a bug which occured when an ActiveDirectoryEntry was refreshed a second time.

  • Fixed a bug with the ActiveDirectoryGroup class

  • Fixed a bug when an DirectoryOperation threw an exception.

Downloads (117,601 Bytes)
Binaries of version 1.1 signed with the InfiniTec private key (108,984 Bytes)
Source files (367,358 Bytes)
Documentation as CHM file.


Posted by Henning Krause on Monday, September 18, 2006 12:00 AM, last modified on Monday, September 18, 2006 12:00 PM
Permalink | Post RSSRSS comment feed

InfiniTec.Exchange 0.95 released

This is another release of my InfiniTec.Exchange package (for a complete list of features see here). This version fixes some bugs and adds Outlook-Object-model like classes, which provides strong-typed access to the properties of the different item types. Supported item types are Appointments, Contacts, Messages and Tasks:

Classdiagram of the outlook-like object model (click to enlarge)


What is missing is a Searcher class which returns instances of those classes. Additionally, recurrence patterns are quite complicated and not implemented in this release. I will add them in a later release.



These are the changes in the 0.95 release:

  • Added the ability to search multiple roots at once to the Searcher class.
  • Renamed Scope enum to Depth
  • Entities in properties are now automatically decoded.
  • Fixed an error in the PROPFIND method
  • Properties with a localname starting with 0x are now correctly handled (for example{00062002-0000-0000-C000-000000000046}/0x0000825e).
  • (Hopefully) fixed a bug with attachments
  • Fixed a bug which occured when saving changes to DateTime properties.
  • Moved several classes between namespaces...
  • New Outlook-Object model like classes: CalendarItem, Contact, Message, Task. Recurrence-handling on tasks and appointments is not currently supported. This will be added with a later release.

Downloads (189,307 Bytes)
InfiniTec.Exchange 0.95 Release files
InfiniTec.Exchange (168,330 Bytes)
InfiniTec.Exchange 0.95 Source files (709,606 Bytes)
Documentation (452,989 Bytes)
Example application


Posted by Henning Krause on Sunday, September 17, 2006 12:00 AM, last modified on Sunday, September 17, 2006 12:00 PM
Permalink | Post RSSRSS comment feed