In an asp.net MVC application, i am encountering the Access denied error when trying to reset the password using directoryEntry.Invoke.
The page is accessed by the user trying to change his/her password and SSL required and Client Certificates - Required are marked in IIS.
Relevant code:
directoryEntry.Invoke("SetPassword", new object[] { model.Password });
directoryEntry.Properties["LockOutTime"].Value = 0;
directoryEntry.Close();
The exact error is –
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
--- End of inner exception stack trace ---
at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)
Web.config –
<authentication mode="Windows" />
<identity impersonate="false" />
<authorization>
<deny users="?" />
</authorization>
- The app pool is running under an AD account; also part of the local
admin group
[Domain1\AppPoolUser]. - The application requests the user certificate
- The user trying to change password
[Domain2\testUser]and the account under which the app pool are running are in different domains but this is not likely an issue. Effective permissions for the AppPoolUser allows ChangePassword on the testUser account. - I even tried running the app pool under the same user account as the test account but it doesn't change anything.
Have checked online but its not clear to me what the issue might be. The closest related thing i see is this - Setting ASP.Net Permissions - Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
However, as mentioned in my case the app pool is running under a limited technical account and i don't think there is any issue with SSL certificates.
- Do i need to request Delegation of Control for the application pool account in the AD?
- Or is there likely another issue that i m missing.