Provisioning Hosted Exchange Users from a Web Page

Originally published July 22, 2005


I wrote last year, in this article, about using a script to provision a hosted Exchange user, and that works well.

Well, I should say, it works well for me. The other folks in the office who have to provision Exchange users, and whose mind doesn't work quite the same way mine does, think that it was unfriendly and difficult to use (they generally stop saying that when I show them how to do it all manually! -- but they still complain).

So, finally, I've put it into a web page. I did this for several reasons: complaints from these folks, the book I'm writing (I needed to proceduralize lots of stuff), and because of a permissions question that arose from readers of the original blog article.

To cut to the chase, you can download the code from:

There were actually two interesting challenges for me. First, I'm not a web programmer anymore, and I had to discover how to do some things without duplicating lots and lots of code between Javascript and VBscript. Secondly, the biggest problem that I had to solve was getting data from Active Directory (which code was run at the server, prior to the webpage being rendered, known as RUNAT=Server) to the client for searches without an ActiveX component (after the webpage was displayed and dependent on user interactions, known as RUNAT=Client).

I learned quite a bit about mixing javascript and vbscript in a single webpage. Then, I threw all of that out, and decided to use vbscript only. It turned out to be much more efficient and short. This required that I use a feature I was previously unaware of in Internet Explorer (and I have no idea if it's available in other browsers) called “event scripts”.

Using event scripts let me do things like this to modify a form-element:

<input name="lastname" maxlength=25 size=25>

<script event="onblur" for="lastname" language="vbscript">
 Dim strLast, strFirst, str, strPass, strChar
 Dim i, j

 ' build a suggestion for the account name
 strLast = Trim (document.buildexch.lastname.value)
 strFirst= Trim (document.buildexch.firstname.value)

 If (Len (strFirst) > 0) And (Len (strLast) > 0) Then
  str = Left (strFirst, 1) & strLast
  i = Len (str)
  document.buildexch.user.value = str
 End If

Granted, you can do similar things with a javascript “onblur='call-function();'”, but this let me stay in vbscript.

Interestingly enough, I had started down the mixed-script route because I had thought that the full DOM (document object model) required javascript. But I was incorrect in that. Everything is available in vbscript as well.

To solve the second problem, I used hidden form fields along with ASP to generate the content of those form fields. Therefore there are several things like this:


that are used to pass small data tables from the backend to the client. These are used in the client-side script in order to validate information and provide suggestions and choices to the end-user.

Neither of these solutions are rocket science, and I'm certain that experienced developers already knew all about these. They are new to me. :-)

To set this up, simply create a virtual directory off the Default Web Site on an Exchange Server (or any server where the Exchange System Management tools are installed). That particular virtual directory needs to have Anonymous access disabled, as shown in this picture:


I also recommend that you disable Basic authentication, as shown in this picture, but that is simply a preference of mine.

The user that is able to create an Exchange user must (assuming no special delegated permissions exist) be member of the Domain Admins security group (from ADUC).

The lib\constants.asp file has the items that you may need to modify to make this work in your environment. Note that the script presumes an environment, as described here. However, the code is quite general purpose, except for the dependence in a few places on OU_HOSTING.

The lib files are just code libraries, that I often reuse for multiple projects, slightly modified to work with ASP files instead of VBS or WSF files.

So, then enter http://server-name/prov/exch.asp and you should be good to go.


Published Tuesday, November 13, 2007 7:57 PM by michael
Filed under: , ,


Monday, August 17, 2009 11:56 PM by rtsoftware

# re: Provisioning Hosted Exchange Users from a Web Page

Excellent work here! I had an odd problem - I had to move the credits comments to an area below the <% Option Explicit %> line item in both xt_exch.asp and exch.asp before it would run on my server. Exchange 2003, Windows 2003, patched up to current. Odd! I fixed that, and it lit right up. Thanks again for a great script.