ADS设置密码方法调用抛出错误

ADS设置密码方法调用抛出错误

问题描述:



我想用VB.NET为活动目录中的用户设置密码。 Active Directory位于另一台服务器中。我收到错误作为内部异常:{访问被拒绝。 (HRESULT异常:0x80070005(E_ACCESSDENIED))}。如果你知道的话请帮助我。谢谢。



objUser.Invoke(SetPassword,strNewPassword)此行只会抛出错误。



objDe =新的DirectoryEntry(Pathweb)



cobjDS =新的DirectorySearcher(objDe)

Hi,
I am tying to set password for user in active directory using VB.NET. The Active Directory is in another server. I am getting error as Inner Exception: "{"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"}". If u know please help me on it. Thank you.

objUser.Invoke("SetPassword", strNewPassword) this line only throwing an error.

objDe = New DirectoryEntry(Pathweb)

cobjDS = New DirectorySearcher(objDe)

cobjDS.Filter = "(&" + str_USER + "(" + str_SEARCH + UserId + "))"

            Dim objSearchResult As SearchResult = cobjDS.FindOne()

            Dim objUser As DirectoryEntry = objSearchResult.GetDirectoryEntry()
            objUser.Invoke("SetPassword", strNewPassword)







我能够在C#中做到这一点。但它需要ADS服务器管理员用户名和密码。在VB.Net中有什么办法吗?

C#代码是。






I am able to do it in C#. But it required ADS server Admin username and password. Is there any way to do in VB.Net.
The C# code is.

PrincipalContext PrincipalContext = new PrincipalContext(ContextType.Domain, ADSServerIP, userpath, ContextOptions.Negotiate, ADSadminuser, ADSadminPSW);
UserPrincipal User = UserPrincipal.FindByIdentity(PrincipalContext, userid);
User.SetPassword(newpassword);

您需要成为域中管理员组的成员才能更改用户密码。如果您确实拥有域管理员的登录详细信息,请尝试使用管理员凭据登录系统并再次运行该应用程序。 Access Denied错误现在应该出现
You need to be member of administrator group in Domain to be able to change the password of users. If you do have the login details of Administrator of the domain, try log in to your system using the administrator credentials and run the application again. Access Denied error should go now




我使用旧密码更改了密码。这次我没有使用Set密码。我使用了更改密码。有效。在C#中。



Hi,
I changed the password using Old password. I am not used the Set password this time. I used the change password. It worked. in C#.

PrincipalContext PrincipalContext = new PrincipalContext(ContextType.Domain, ConfigurationManager.AppSettings["ADSServerIP"].ToString(), usertype);
            UserPrincipal User = UserPrincipal.FindByIdentity(PrincipalContext, userid);
            User.ChangePassword(strOldPassword, newpassword);