Note that there are some explanatory texts on larger screens.

plurals
  1. POActive directory - exception has been thrown by the target of an invocation
    text
    copied!<p>I have a web application in a separate server than Active Directory and I want to change a user password. The code is the next:</p> <pre><code>string newPassword = Membership.GeneratePassword(int.Parse(WebConfigurationManager.AppSettings["passLenght"]), int.Parse(WebConfigurationManager.AppSettings["passNonAlpha"])); DirectoryEntry de = new DirectoryEntry(WebConfigurationManager.ConnectionStrings["ADConnString"].ConnectionString, WebConfigurationManager.AppSettings["ADAdmin"], WebConfigurationManager.AppSettings["ADAdminPass"]); DirectorySearcher deSearch = new DirectorySearcher(de); deSearch.Filter = "(&amp;(objectClass=user) (userPrincipalName=" + name + "))"; SearchResultCollection results = deSearch.FindAll(); if (results.Count == 1) { foreach (SearchResult OneSearchResult in results) { DirectoryEntry AlterUser = OneSearchResult.GetDirectoryEntry(); AlterUser.AuthenticationType = AuthenticationTypes.Secure; AlterUser.Invoke("SetPassword", newPassword); AlterUser.CommitChanges(); AlterUser.Close(); } } </code></pre> <p>When I run this in my development environment (where Active Directory and the web application are on the same server) it is working. But when I try to run it in the production environment I am having the next error:</p> <blockquote> <p>Exception has been thrown by the target of an invocation</p> </blockquote> <p>What am I missing?</p> <p>Thanks.</p> <p>EDIT:</p> <p>I could go deep in the exception error and I get this:</p> <blockquote> <p>Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload