C# active directory update unknown error for 2 people


I have a C# console application that updates Active Directory properties using data from the HR system.

Below is a sample of the code I'm using to update the manager property:-

if (ADManagerPath != adManager)
    if (enableActiveDirectoryUpdates)
        if (ADManagerPath.Length > 0)
            deLDAPUpdate.Properties["manager"].Value = ADManagerPath;
    managerChanged = true;

Obviously, there are other properties that I am updating and finally if I have made any changes, there is a CommitChanges statement.

My issue is that the line will I am setting the manager, fails but only for 2 active directory accounts (which may well be for the same person).

The error codes I am receiving are (0x80005000) -2147463168. I have searched the site, and others, however most answers appear to be cases where LDAP has not been capitalized or the property/attribute you're trying to update does not exist. Both of which I do not believe apply to my situation, as I can update other accounts.

Can anybody help?

Okay I have fixed the above problem but still have a problem with these 2 accounts. The value I was reading from a database, somehow had an extra backslash in the manager path and that was the problem for setting the manager. My program now successfully can update a person's manager to 1 of these 2 accounts.

However I still believe there is a problem with the 2 accounts in question. I cannot set any property for the 2 accounts in question. Interestingly, I have developed a program, only for my use, where you enter a samAccountName and it will display and iterate through all the properties. However, this program also falls over when I attempt to use it on either of these accounts.

I write any errors to an exception table and all that error message says is "Unknown error (0x80005000)".

This program has been running for a couple of months, although it has been developed further over the past few weeks, and it is only these 2 accounts that will not update?

The code that I am using to create the various active directory connection objects is:-

string gcConnection = "GC://" + guidBindRootPath + "/<GUID=" + adID + ">";
        deGUIDBind.Username = username;
        deGUIDBind.Password = password;
        deGUIDBind.AuthenticationType = AuthenticationTypes.Secure;
        deGUIDBind.Path = gcConnection;

        deLDAPUpdate.Username = username;
        deLDAPUpdate.Password = password;
        deLDAPUpdate.AuthenticationType = AuthenticationTypes.Secure;
        string distinguishedName = deGUIDBind.Properties["distinguishedName"].Value.ToString();
        string ldapConnection = "LDAP://" + getDomainNameFromDistinguishedName(distinguishedName) + "/" + distinguishedName;
        deLDAPUpdate.Path = ldapConnection;

` To reiterate, I have solved the problem of setting, the accounts in question, as the manager of other accounts, however, I can still not change any of the properties of the 2 problematic accounts. My program successfully updates other accounts.

The other program that I have written, in C#, which iterates through and displays all the properties, for a given samAccountName, also falls over for these 2 accounts.

                string adDivision = convertNullToString(deLDAPUpdate.Properties["Division"].Value);
            propertyDetails = propertyDetails + "Division" + "," + adDivision + Environment.NewLine;

            foreach (System.DirectoryServices.PropertyValueCollection p in deLDAPUpdate.Properties)

With regard to the 2 problem accounts, this program falls over both on attempt to retrieve the division property and also when it attains to evaluate deLDAPUpdate.Properties.

I am not asking for help with the 2nd application, which is only for my own use, I only mention it since it seems to indicate that there might be a problem with the 2 accounts. This test application successfully displays the properties of other accounts.

asked on Stack Overflow Jun 10, 2020 by Wheels496 • edited Jun 12, 2020 by Wheels496

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0