Greetings!
I currently use the code below to allow the users of my application to change their Windows 2000 password.
However, it does not seem to work on a consistent basis.
Could someone possibly provide me with either an explanation for this or an alternative method?
Thanks in advance
Dominic >
:O>
The code is as follows:
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 Sub Command1_Click()
Dim R As Long
Dim sServer As String
Dim sUser As String
Dim sOldPass As String
Dim sNewPass As String
sServer = StrConv("\\<server-name>" & strServer, vbUnicode)
sUser = StrConv(<username>, vbUnicode)
sOldPass = StrConv(<old-password>, vbUnicode)
sNewPass = StrConv(<new-password>, vbUnicode)
R = NetUserChangePassword(sServer, sUser, sOldPass, sNewPass)
If R <> 0 Then
' Generate error message
Else
Msgbox "Password Changed Successfully"
End If
End Sub
I currently use the code below to allow the users of my application to change their Windows 2000 password.
However, it does not seem to work on a consistent basis.
Could someone possibly provide me with either an explanation for this or an alternative method?
Thanks in advance
Dominic >
The code is as follows:
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 Sub Command1_Click()
Dim R As Long
Dim sServer As String
Dim sUser As String
Dim sOldPass As String
Dim sNewPass As String
sServer = StrConv("\\<server-name>" & strServer, vbUnicode)
sUser = StrConv(<username>, vbUnicode)
sOldPass = StrConv(<old-password>, vbUnicode)
sNewPass = StrConv(<new-password>, vbUnicode)
R = NetUserChangePassword(sServer, sUser, sOldPass, sNewPass)
If R <> 0 Then
' Generate error message
Else
Msgbox "Password Changed Successfully"
End If
End Sub