uot; (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function NetGetDCName _
Lib "netapi32.dll" (ServerName As Long, domainname As Byte, bufptr As Long) As Long
Private Declare Sub lstrcpyW Lib "kernel32" (dest As Any, ByVal src As Any)
Private Declare Function NetApiBufferFree& Lib "netapi32" (ByVal Buffer As Long)
'' 常量
Private Const EVENTLOG_ERROR_TYPE = 1
Private Const EVENTLOG_INFORMATION_TYPE = 4
(9)新增一个过程SetPassword:
'' change the user''s password
Public Sub SetPassword(ByVal pstrUser As String, _
ByVal pstrOldPassword As String, ByVal pstrNewPassword _
As String, ByVal pstrConfirmPassword As String)
Dim adsUser As IADsUser
Dim strDialogText As String
On Error GoTo ChangePasswordErrorHandler
'' 引用MTS对象
Call GetObjectReferences
If pstrUser <> vbNullString Then
If (Not (pstrOldPassword = vbNullString)) And _
(Not (pstrNewPassword = vbNullString)) Then
If (Not (pstrNewPassword <> pstrConfirmPassword)) Then
'' 设置ADSI路径,将INTRANET改成你自己的域名。
Set adsUser = GetObject("WinNT://INTRANET/" & pstrUser & ",user")
'' 修改口令
adsUser.ChangePassword pstrOldPassword, pstrNewPassword
'' 产生日志
Call LogNTEvent("用户 " & pstrUser & _
" 修改口令成功。", EVENTLOG_INFORMATION_TYPE, 1001)
'' generate the alert dialog HTML
strDialogText = """用户 " & pstrUser & " 口令修改成功!"""
Call CreateAlertMarkup(strDialogText)
Else
'' generate the alert dialog HTML
strDialogText = """两次敲的口令不相同,禁止修改。"""
&