Get unknown error (0x80005000) when running code: set password user account

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(); 
} 
c#
active-directory
asked on Stack Overflow Jul 8, 2010 by user383659 • edited Jul 8, 2010 by marc_s

1 Answer

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?

answered on Stack Overflow Jul 8, 2010 by marc_s

User contributions licensed under CC BY-SA 3.0