怎样修改win2000用户的密码

minglovelcy 2003-09-26 05:37:24
请问各位大哥,怎样可以修改win2000用户的密码,怎样写程序去添加,删除用户,请指教!:)
...全文
77 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
pigpag 2003-10-02
  • 打赏
  • 举报
回复
可以用GetObject对象化操作。寻找详细资料中……
goodname008 2003-10-01
  • 打赏
  • 举报
回复
可以用Shell函数调用net命令来实现,简单方便。
aha99 2003-09-29
  • 打赏
  • 举报
回复
还有其他办法吗?up
aha99 2003-09-29
  • 打赏
  • 举报
回复
我记得不是这样的呀。。。
qdkcy 2003-09-29
  • 打赏
  • 举报
回复
做过在客户端修改服务器的组件,你看看
'***** *****ÒÔÏÂÓÃÓÚÐÞ¸ÄÓû§ÃÜÂë***** *****
Private Declare Function NetUserChangePassword Lib "NETAPI32.DLL" _
(ByVal domainname As String, _
ByVal username As String, _
ByVal oldpassword As String, _
ByVal newpassword As String) As Long

Private Declare Function NetUserSetInfo Lib "NETAPI32.DLL" _
(ByVal servername As String, _
ByVal username As String, _
ByVal Level As Long, _
UserInfo As Any, _
ParmError As Long) As Long


Private Type USER_INFO_1003
usri1003_password As Long
End Type

'Private Const ERROR_ACCESS_DENIED = 5&
Private Const ERROR_INVALID_PASSWORD = 86&
Private Const NERR_InvalidComputer = 2351
Private Const NERR_NotPrimary = 2226
Private Const NERR_UserNotFound = 2221
Private Const NERR_PasswordTooShort = 2245
Private Const ERROR_CANT_ACCESS_DOMAIN_INFO = 1351
'***** *****ÒÔÉÏÓÃÓÚÐÞ¸ÄÓû§ÃÜÂë***** *****

Public Function ChangeUserPassword(ByVal strUserName As String, ByVal strOldPassword As String, ByVal strNewPassword As String) As String
Dim lngWin32apiResultCode As Long
Dim strServerName As String
Dim udtUserInfo1003 As USER_INFO_1003
Dim lngParmErr As Long
Dim msg As String


'strServerName = StrConv(Environ("USERDOMAIN"), vbUnicode)
strServerName = StrConv(GetMyComputerName(), vbUnicode)
strUserName = StrConv(strUserName, vbUnicode)
'MyResponse.Write GetMyComputerName()
If strOldPassword = "" Then
udtUserInfo1003.usri1003_password = StrPtr(strNewPassword)
lngWin32apiResultCode = NetUserSetInfo(strServerName, _
strUserName, _
1003, _
udtUserInfo1003, _
lngParmErr)
Else
strOldPassword = StrConv(strOldPassword, vbUnicode)
strNewPassword = StrConv(strNewPassword, vbUnicode)

lngWin32apiResultCode = NetUserChangePassword(strServerName, _
strUserName, _
strOldPassword, _
strNewPassword)
End If

Select Case lngWin32apiResultCode
Case ERROR_ACCESS_DENIED: msg = "Error: Access denied."
Case ERROR_INVALID_PASSWORD: msg = "Error: Invalid password."
Case NERR_InvalidComputer: msg = "Error: Invalid Computer-/Domainname."
Case NERR_NotPrimary: msg = "Error: This operation can only performed on the primary domain controler."
Case NERR_UserNotFound: msg = "Error: User not found."
Case NERR_PasswordTooShort: msg = "Error: Password does not match Password-Restrictions. (Password to short, to long or has already been used by this user.)"
Case ERROR_CANT_ACCESS_DOMAIN_INFO
msg = "Error: Error accessing info for domain controler. Maybe the computer is not available or access was denied."
Case 0: msg = "Operation performed successfully."
Case Else: msg = "Error: Unexpected Error " & Err.Description & " occured."
End Select

ChangeUserPassword = msg
End Function
'
'
'Public Function DOSChangePwd(ByVal strUserName As String, ByVal strNewPassword As String) As Boolean
'Dim IsSuccess
'Dim oScript As Object
'
''On Error Resume Next
'Set oScript = CreateObject("WSCRIPT.SHELL")
'
'IsSuccess = oScript.Run("cmd.exe /c net user " & strUserName & " " & strNewPassword, 0, True)
'If IsSuccess <> 0 Then
' DOSChangePwd = False
'Else
' DOSChangePwd = True
'End If
'Set oScript = Nothing
'End Function
aha99 2003-09-27
  • 打赏
  • 举报
回复
看过这方面的资料,回头查查,当时没太注意。。。

1,488

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧