Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Chnaging the Windows 2000 Password programmatically

Status
Not open for further replies.

dleiba

MIS
Aug 22, 2001
28
JM
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(&quot;\\<server-name>&quot; & 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 &quot;Password Changed Successfully&quot;
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top