开发者

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

开发者 https://www.devze.com 2023-01-06 15:18 出处:网络
This code failed on this line with unknown error (0x80005000) using System; using System.DirectoryServices;

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+"//"+E开发者_开发知识库nvironment.UserName; 

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


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消