Windows 2008 Domain Control Access Denied Error in C#

Asked By 60 points N/A Posted on -
qa-featured

 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.

SHARE
Answered By 0 points N/A #147913

Windows 2008 Domain Control Access Denied Error in C#

qa-featured

Hello Centic,

The Windows 2008 Domain Controller is most  probably not transferring credentials to the user  DirectoryEntry. So instead of reusing the DirectoryEntry 'dsUser',  you will need to attempt creating a new one and see if the credentials might transfer in this case. If it is not possible that way, you will then need to bind to it again using password and username.

Regards,

Nicke

Related Questions