Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

Creation of new user accounts crashing on setting of proxyAddresses attribute.

Last post 08-11-2010, 9:53 PM by serious. 4 replies.
Sort Posts: Previous Next
  •  07-27-2010, 8:42 AM 8494

    Creation of new user accounts crashing on setting of proxyAddresses attribute.

    Hi everyone,

    We are developing a script that creates Active Directory accounts. We have a test domain in place and so far we have successfully created about 100,000 user accounts without any mishap. However, we had trouble creating 3000 accounts and it appears to be caused by incorrectly setting the proxyAddresses attribute. Creation of new accounts is problematic but I can update the proxyAddresses value (the same value that crashed during the creation of a new account) once an account has been created.

    The code I've been using is shown below. A sample proxyAddress string is also provided. Basically the proxyAddresses cache is cleared during each run of the script and then the new proxyAddresses value is set. Once again this problem only occurs during the creation of a new user account. It works just fine once an account has been created. Any help would be greatly appreciated. Thanks.

    /* sample proxyAddress */
    SMTP:org-7@icex.test.com%SMTP:org-7%SMTP:org-7@test.com%SMTP:org-7@test.com

    user.Properties["proxyAddresses"].Clear(); // clears the proxyAddresses cache
    smtp = getSmtpValues(proxyAddresses); //breaks up the proxyAddresses and stores it into an Array

    foreach (string proxyAddress in smtp)
    {
          user.Properties["proxyAddresses"].Add(proxyAddress);
     }

    public static ArrayList getSmtpValues(string values)
    {
                ArrayList smtpList = new ArrayList();

                string[] smtp = values.Split(new char[] { '%' }); // sets % as the delimitter

                foreach (string address in smtp)
                {
                    smtpList.Add(address);
                }

                return smtpList;

    }
  •  07-27-2010, 10:02 AM 8496 in reply to 8494

    Re: Creation of new user accounts crashing on setting of proxyAddresses attribute.

    Need exception to be able to tell you anything definitive.

    However, "SMTP:" in upper case designates a primary smtp address. Secondaries should be prefixed with "smtp:".

    Not sure why you are clearing proxyAddresses on a new account creation because it is already null.

    You shouldn't have to put the values into an arraylist. Once you have split the addresses into an array of string, you can use the AddRange method to push them in.
  •  07-27-2010, 10:16 AM 8497 in reply to 8496

    Re: Creation of new user accounts crashing on setting of proxyAddresses attribute.

    Oops forgot to include the exception! The exception is shown below:

    "A constraint violation occurred. (Exception from HRESULT: 0x8007202F)"

    It's not a very helpful exception I know.

    I'm clearing proxyAddresses on a new account creation because it's part of a function that's called during new account creation or when updating the attributes of an existing user account. Thanks again.
  •  08-10-2010, 6:53 PM 8507 in reply to 8497

    Re: Creation of new user accounts crashing on setting of proxyAddresses attribute.

    Normally when you get a constraint violation thrown, either the data type is incorrect (should be string), there is a character limit that has been exceeded or some other limit has been tripped.

    Check out the attributeSchema object for proxyAddresses and see what limits there are.

    If I had to guess, the fact that you have multiple "SMTP:" in upper case in your string array, it may throw an exception because you can only have a maximum of 1 primary smtp address per object.


  •  08-11-2010, 9:53 PM 8508 in reply to 8507

    Re: Creation of new user accounts crashing on setting of proxyAddresses attribute.

    I can't tell from the description given at what point the violation is occuring. Could it be the clearing of the proxyAddresses? If they are null, would this cause a violation (I ask because I've had similar issues in attempting to set a property when it was not on the account yet, so the property didn't exist in the cache)? I thought it may be a conflicting duplicated proxyAddress, however it appears it doesn't cause a problem in ADUC's attribute editor for me to add a duplicate proxy address: although Exchange didn't like it at all due to the duplicate.
    IANA.NPBISFTU
    (I am not a .net programmer but I still find this useful)
View as RSS news feed in XML