Adding a Hosted Exchange User With VBScript - Patch 1
Originally published October 5, 2004
OK, I knew there would be bugs. :-) The first bug someone found is that the original script doesn't verify uniqueness of the User Principal Name. As I discuss elsewhere, Active Directory doesn't verify that either (which could be considered a bug in A/D, in my opinion).
Here is the fix.
In the CreateHostedUser subroutine, add this right after the DIM statements:
strSearch = "<LDAP://" & strNamingContext & ">;" & _
"(&(objectclass=user)(objectcategory=person)(userPrincipalName=" & strAccountName & "@" & strDomain & "));" & _
Call DoLDAPQuery (strSearch, Rs)
While Not Rs.EOF
e "*** Error: user already exists: " & strAccountName & "@" & strDomain
Call FinishLDAPQuery (Rs)