header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Subject: mail address in use - ldap language issue with æøå
Prev Next
You are not authorized to post a reply.

Author Messages
FrodeDUser is Offline
New Member
New Member
Posts:9

05/27/2008 8:25 AM  

Hi, I have been using the function below to check if the wanted mail address is already in use. This to avoid any error/conflict while creating new mailboxes.

Unfortunately I now find that the LDAP query also return some false positive hits. This happens when there is a invalid smtp address containing the norwegian "æøå" inside the smtp address, and you query for a mail address which is similar but with valid characters.

Say we have a user with a mail proxy address list like this:

ole.olsen@yourdomain.no

ole.ølsen@yourdomain.com   # this is not a valid smtp, but I have such entries in my AD which I must remove ...

Now suppose you want to query if ole.olsen@yourdomain.com is free to use... then you would get a false positive hit claiming that the address is already in use ...

I find no logical reason why this should happen, anyone able to enlighten me?

I know that LDAP query is case insensitive, but have no reason to suspect it would automatically replace "o" with "ø" in the query above. This just might be a LDAP speciality aka danish-norwegian query settings in SQL server...

 

function MailAddressInUse([string]$MailAddress) {
 # check if the mail address is used in Exchange
 # For ANR searches see http://support.microsoft.com/kb/243299
 if (!$MailAddress) {break}
 
 $root = [ADSI]""
 $AD_searcher = new-object DirectoryServices.DirectorySearcher($root)
 
 # only return enabled user accounts with a matching mail address or any proxy addresses !
 # (sAMAccountType=805306368) is the same effekt as (&(objectCategory=person)(objectClass=User)) but much faster
 # disabled accounts have: (userAccountControl:1.2.840.113556.1.4.803:=2)
 $AD_searcher.filter = "(&(sAMAccountType=805306368)(!userAccountControl:1.2.840.113556.1.4.803:=2)(proxyAddresses=smtp:" + $MailAddress + "))"
 $AD_searcher.CacheResults = $True
 $AD_searcher.SearchScope = "Subtree"
 $AD_searcher.PageSize = 1000
 $UserColl = $AD_searcher.findone() # do the search and return a SearchResultCollection
 
 # write-host("AD search done.")
 
 if ($UserColl) {
  $User = [ADSI]$UserColl.path
  write-host("Mail address " + $MailAddress + " in use for " + $User.displayName + " in object " + $UserColl.path)
  return $True
 }
 else {
  write-host("Mail address " + $MailAddress + " is not in use")
  return $False
 }
}

# test of function call
MailAddressInUse "someone@yourdomain.com"

 

 

You are not authorized to post a reply.
Forums > Using PowerShell > Exchange Server > mail address in use - ldap language issue with æøå



ActiveForums 3.7
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer