0

This code failed on this line with unknown error (0x80005000)

using System; 
using System.DirectoryServices; 

// correct the userPath!!! 
string userPath = "WinNT://"+Environment.MachineName+"/"+Environment.UserDomainName+"//"+Environment.UserName; 

using (DirectoryEntry userEntry = new DirectoryEntry(userPath)) 
{ 
    object[] password = new object[] {"newPwd", "oldPwd"}; 
    object ret = userEntry.Invoke("ChangePassword", password); 
    userEntry.CommitChanges(); 
} 
0

1 Answer 1

1

You should try to avoid using the WinNT: provider for ADSI - it's old, it's only there for backward compatibility, and it's severely limited in its capabilities.

Is this a user account in a network environment? If so, use the LDAP:// provider instead - it's much more powerful and more flexible in many ways.

Where exactly is your code failling? It's not clear from your post. On the .Invoke() or on the .CommitChanges() call?

5
  • I change to LDAP:// I still get error on the .Invoke() thanks
    – user383659
    Jul 8, 2010 at 11:38
  • Show me the code you're using for the LDAP version! What is the "userpath" look like??
    – marc_s
    Jul 8, 2010 at 11:53
  • "LDAP://"+ Environment.MachineName+"/"+Environment.UserName; - the user is Domain user...
    – user383659
    Jul 8, 2010 at 12:04
  • That is not going to work! The LDAP path is not the same as the WinNT path ! Are you on a Windows network here? Or just a local machine??
    – marc_s
    Jul 8, 2010 at 12:25
  • 1
    Then your LDAP path should be something like: LDAP://DCserver/cn=Your User,cn=Users,dc=YourCompany,dc=com. Check out Sysinternals' AD Explorer tool (technet.microsoft.com/en-us/sysinternals/bb963907.aspx) for understanding how your AD and your paths in LDAP look like
    – marc_s
    Jul 8, 2010 at 15:28

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.