在软件登录的时候使用系统的Administrator用户进行身份验证,如何实现?
我试图用NetUserChangePassword来验证密码,可是我的程序注册成了服务,必须将服务设置为
Administrator登录时才能够调用NetUserChangePassword成功,否则就会返回未知的错误码。我也不知道为什么。
哪位能否提供一些思路?先谢谢了。

解决方案 »

  1.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt/netuserchangepassword.aspIn some cases, the process that calls the NetUserChangePassword function must also have the SE_CHANGE_NOTIFY_NAME privilege enabled; otherwise, NetUserChangePassword fails and GetLastError returns ERROR_ACCESS_DENIED. This privilege is not required for the LocalSystem account or for accounts that are members of the administrators group. By default, SE_CHANGE_NOTIFY_NAME is enabled for all users, but some administrators may disable the privilege for everyone. For more information about account privileges, see Privileges and Authorization Constants
      

  2.   

    NetUserChangePassword的返回错误码为1351,并非winAPI提供的那几个错误码(ERROR_ACCESS_DENIED、ERROR_INVALID_PASSWORD、NERR_InvalidComputer、NERR_NotPrimary、NERR_UserNotFound、NERR_PasswordTooShort、NERR_Success)之一,我把服务的属性的“登录”中修改为Administrator登录就可以了,但是这种解决方法不知道好不好,我也不知道这是什么原因,请高手讲解一下。最好能够提供一个好的解决方法。