Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: NetUserChangePassword Question


Message #1 by lamont.adams@t... on Thu, 12 Apr 2001 14:45:34
Hi Lamont,

take a look at the MSDN Library and there you'll find the following 
description for the parameters you have to pass:

---------------------------------------------------------------------------
domainname 
[in] Pointer to a constant null-terminated Unicode string that specifies 
the name of a remote server or domain. The NetUserChangePassword function 
changes the user's password on the specified remote server or domain. 
If this parameter is NULL, the logon domain of the caller is used. 

username 
[in] Pointer to a constant null-terminated Unicode string that specifies a 
user name. The NetUserChangePassword function changes the password for the 
specified user. 
If this parameter is NULL, the logon name of the caller is used. 

oldpassword 
[in] Pointer to a constant null-terminated Unicode string that specifies 
the user's old password. 

newpassword 
[in] Pointer to a constant null-terminated Unicode string that specifies 
the user's new password
---------------------------------------------------------------------------

First of all, always try to avoid 'Any' as your parameter type. You'll 
always have Problems with this declaration type. Better use 'String' or 
'Long' depending on wether it is an in or out parameter. So better try 
this declaration:

Private Declare Function NetUserChangePassword Lib "Netapi32.dll" (Domain 
As String, User As String, OldPass As String, NewPass As String) As Long

Taking a closer look at the parameters 'domain' and 'username', you will 
notice that you are allowed to pass NULL-Values. Try this with the VB 
constant 'vbNullString'. Because you always have to have null-terminated 
strings, don't forget to terminate your strings with 'vbNullChar'.

I haven't tested the above declaration, so you still may have some trouble 
with Unicode.

Hope this helps a little
Boris

  Return to Index