Windows 2008 Domain Control Access Denied Error in C#
Hello,
I’m currently working on a C# console application for a client that brings a custom AD field up-to-date. This application is run on 2 domain controllers by the customer. The problem is that on the Windows 2008 Domain Control when the Application reaches the Commit Changes statement, a “General Access Denied” error is received. I can fix the issue by hard-coding the login details into the Directory Entry connection or keeping them in app.config, but this is not the appropriate solution. The Application works without any errors on the Windows 2003 Domain Controller. Here’s my code:
Code works on Windows 2003 Domain Controller but not on Windows 2008 Domain Controller
DirectoryEntry tmpADEntry = new DirectoryEntry(ADResult.Path);
tmpADEntry.Properties["employeeId"].Value = tmpEmpId.ToString();
tmpADEntry.CommitChanges();
Code works on Windows 2003 Domain Controller and Windows 2008 Domain Controller
DirectoryEntry tmpADEntry = new DirectoryEntry(ADResult.Path,ConfigurationManager.AppSettings["myADAdminUsername"], ConfigurationManager.AppSettings["myADAdminPassword"], AuthenticationTypes.Secure); tmpADEntry.Properties["employeeId"].Value = tmpEmpId.ToString();
tmpADEntry.CommitChanges();
Can anyone see where I have made an error in my code? Any help is appreciated.