1
The issue you're encountering with creating Active Directory (AD) accounts containing numbers in the Display Name or Email Address may stem from validation constraints introduced after upgrading to Exchange 2016 CU8.
Your .NET code uses System.DirectoryServices to create a mailbox and update its attributes in a two-step process. While the mailbox creation succeeds, updating attributes fails with an error indicating the mailbox or sAMAccountName doesn’t exist, and the object is eventually deleted.
To debug, make sure the strPrimarySmtpAddress and strName are correctly formatted, especially when appending numbers, as shown in your code:
strPrimarySmtpAddress = dr["firstName"].ToString().Replace(" ", "").Replace(".", "") + "." + dr["lastName"].ToString().Replace(" ", "").Replace(".", "") + i.ToString() + strSMTPDomain;
strName = dr["firstName"].ToString().Replace(".", "") + " " + dr["lastName"].ToString().Replace(".", "") + " " + dr["workerID"].ToString();
Aslo , you need to verify that no naming constraints or custom scripts are enforcing restrictions on numeric characters.
try {
powershell.Invoke();
} catch (Exception ex) {
WriteToErrorLog("Error creating mailbox", ex.Message, "Application Exception");
}
