Change user password in active directory.http://forums.asp.net/t/1361779.aspx/1?Change+user+password+in+active+directory+Thu, 08 Jan 2009 22:45:25 -050013617792814503http://forums.asp.net/p/1361779/2814503.aspx/1?Change+user+password+in+active+directory+Change user password in active directory. Hi All, To change the password in active directory I have used the following code but i`m getting exception saying as Unknown error (0x80005000). Please some body help me in solving out this problem. I tried to run the &quot;LADP://192.168.1.15 in run cmd but its giving an error msg saying as --------------------------- Find People --------------------------- An error occurred while performing the search. Your computer, your Internet service provider, or the specified directory service may be disconnected. Check your connections and try again. Operations Error --------------------------- OK --------------------------- Is that exception because of this error or it is something else suggest me how can I sole this . This is my code: ADPath = &quot;LADP://192.168.1.15; DirectoryEntry oDE; oDE = new DirectoryEntry(ADPath, ADUser, ADPassword, AuthenticationTypes.Secure); try { // Change the password. oDE.Invoke(&quot;ChangePassword&quot;, new object[]{strOldPassword, strNewPassword}); } catch (Exception excep) { Debug.WriteLine(&quot;Error changing password. Reason: &quot; &#43; excep.Message); } 2008-12-17T05:43:51-05:002814714http://forums.asp.net/p/1361779/2814714.aspx/1?Re+Change+user+password+in+active+directory+Re: Change user password in active directory. <p>Changing Passwords With Active Directory Can Sometimes be very [:'(] (painful).</p> <p>I have used this code many times in the past, note the ldap path..</p> <pre class="prettyprint">if (newpassword.Text.ToString() == checknewpassword.Text.ToString()) { // Just fetch the user's XXXX\xxx login name SPWeb webContext = SPControl.GetContextWeb(Context); string strLoginName = webContext.CurrentUser.LoginName; int iPosition = strLoginName.IndexOf(&quot;\\&quot;) &#43; 1; strLoginName = strLoginName.Substring(iPosition); DirectoryEntry entry = new DirectoryEntry(&quot;LDAP://blfoley.local&quot;, strLoginName, oldpassword.Text.ToString(),AuthenticationTypes.Secure); DirectorySearcher search = new DirectorySearcher(entry); search.Filter = &quot;(SAMAccountName=&quot; &#43; strLoginName &#43; &quot;)&quot;; search.SearchScope = SearchScope.Subtree; search.CacheResults = false; SearchResultCollection results = search.FindAll(); if (results.Count &gt; 0) { foreach (SearchResult result in results) { try { entry = result.GetDirectoryEntry(); } catch (Exception error) { output.Text &#43;= &quot;&quot; &#43; error.Message.ToString(); } } try { entry.Invoke(&quot;ChangePassword&quot;, new object[] { oldpassword.Text.ToString(), newpassword.Text.ToString() }); entry.CommitChanges(); output.Text &#43;= &quot;Password is changed&quot;; } catch (Exception) { output.Text &#43;= &quot;<b> Password couldn't be changed due to restrictions&lt;b&gt;&quot;;</b> } } else { output.Text &#43;= &quot;&amp;lt;BR&gt; User not found or bad password&quot;; } } else { output.Text &#43;= &quot;&amp;lt;BR&gt;Passwords don't match&quot;; }</pre>&nbsp; 2008-12-17T07:25:37-05:002831699http://forums.asp.net/p/1361779/2831699.aspx/1?Re+Change+user+password+in+active+directory+Re: Change user password in active directory. Hi , I used the above code but it give exception once it return back from the invoke function . I mean once it reach line no 36 before coming to line 37 it goes to catch and gives error message saying Undisclosed exception . 2008-12-26T08:18:53-05:002853817http://forums.asp.net/p/1361779/2853817.aspx/1?Re+Change+user+password+in+active+directory+Re: Change user password in active directory. Can anybody help on this pls 2009-01-08T08:38:12-05:002855452http://forums.asp.net/p/1361779/2855452.aspx/1?Re+Change+user+password+in+active+directory+Re: Change user password in active directory. <p>A couple of things you need to check:<br> <br> Does the user that is executing the code have permission in active directory to change a password?<br> Is Impersonation turned on?<br> What were the specifics of the inner exception?<br> did the DirectoryEntry come back correctly?</p> 2009-01-08T22:45:25-05:00