Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 密码过期时如何在active directory中更改密码_C#_.net_Active Directory_Ldap - Fatal编程技术网

C# 密码过期时如何在active directory中更改密码

C# 密码过期时如何在active directory中更改密码,c#,.net,active-directory,ldap,C#,.net,Active Directory,Ldap,在Microsoft Active Directory(AD)中,如果某人的密码过期,如何使用其旧密码更改密码 我知道系统。DirectoryService有一个ChangePassword方法,但是当密码过期时它就不工作了 我比你更需要帮助 顺便说一句,不能使用SetPassword方法,因为它必须具有特权。您可以使用netapi32.dll中的函数 [DllImport("netapi32.dll", CharSet=CharSet.Unicode, CallingConventio

在Microsoft Active Directory(AD)中,如果某人的密码过期,如何使用其旧密码更改密码

我知道
系统。DirectoryService
有一个
ChangePassword
方法,但是当密码过期时它就不工作了

我比你更需要帮助

顺便说一句,不能使用
SetPassword
方法,因为它必须具有特权。

您可以使用netapi32.dll中的函数

[DllImport("netapi32.dll", CharSet=CharSet.Unicode,
    CallingConvention=CallingConvention.StdCall,
    SetLastError=true )]
static extern uint NetUserChangePassword (
    [MarshalAs(UnmanagedType.LPWStr)] string domainname,
    [MarshalAs(UnmanagedType.LPWStr)] string username,
    [MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
    [MarshalAs(UnmanagedType.LPWStr)] string newpassword
);