How to change user's NT password ? 
Author Message
 How to change user's NT password ?

Hi there,

I have to make a program to control users' access in a WindowsTerminalServer
by enabling and disabling their passwords.
Is there any API call to change users' password ?

Thanks for your help,
Sato



Tue, 19 Mar 2002 03:00:00 GMT  
 How to change user's NT password ?
On Fri, 01 Oct 1999 18:36:19 -0400, Mike Zelikovich

Quote:

><!doctype html public "-//w3c//dtd html 4.0 transitional//en">
><html>
>Hi Sato.
><br>Below is the code you need to use in a module to change the NT logon
>password of a user.
><p>'-----------------------------------
><br>'The lpBuf argument in NetUserSetInfo HAS TO BE PASSED ByVal
><br>Declare Function NetUserSetInfo Lib "Netapi32.dll" _
><br>???????????????
>(lpServerName As Byte, _

[snip]

This is what your message looks like to others. Plese don't post in
HTML.

--
Never underestimate the power of stupid people on large groups.



Wed, 20 Mar 2002 03:00:00 GMT  
 How to change user's NT password ?
On Mon, 04 Oct 1999 09:08:14 -0400, Mike Zelikovich

[snip]

Quote:
>Now adays, if you have a modem good enough to get you out on Inet and surf
>microsoft new groups, your browser should pretty much be able to read html
>tags.

What does my modem have to do with my newsreader? You want me to ditch
Agent for Outlook?

Quote:
><br>Anyway, I switched my settings to send in plain text and html - shoudl
>solve the problem

Nope... still there. Blank message, HTML attachment.

--
Never underestimate the power of stupid people on large groups.



Fri, 22 Mar 2002 03:00:00 GMT  
 How to change user's NT password ?
hy,

i have a problem which seems to be very similar:

is there a possibility to check if a given username/password combination is
correct?

very usefull would be a method which accepts a servername and username and
returns the pasword (or a userinfo object which contains the password).

where can i find a documentation of the netapi32.dll? (i looked it up in
msdn but found nothing)

greetings
paul

  Hi Sato.
  Below is the code you need to use in a module to change the NT logon
password of a user.
  '-----------------------------------
  'The lpBuf argument in NetUserSetInfo HAS TO BE PASSED ByVal
  Declare Function NetUserSetInfo Lib "Netapi32.dll" _
                  (lpServerName As Byte, _
                   lpUserName As Byte, _
                   ByVal Level As Long, _
                   ByVal lpBuf As Long, _
                   ByVal Parm_Err As Long) As Long
  Declare Function NetApiBufferAllocate Lib "Netapi32.dll" (ByVal ByteCount
As Long, lpBuffer As Long) As Long
  Declare Function StrToPtr Lib "kernel32" Alias "lstrcpyW" _
                  (ByVal Ptr As Long, Source As Byte) As Long
  'USER_INFO_1003 is used by the NetUserSetInfo function to change user
passwords
  Type USER_INFO_1003
     NewPassWord As Long
  End Type

  Public Function zChangeNetworkUserPassword(ByVal lpUserName As String, _
                                             ByVal lpPassword As String) As
Long
  '***DESCRIPTION: This function is used to change a network user's
  '                password (requires admin privilages).
  '***PARAMETERS:
  ' 1. lpUserName - Specifies the UserName of the user whose password
  '                 is being changed.
  ' 2. lpPassword - Specifies the new password for the user.

  '***RV: This function returns error codes returned by the NetUserSetInfo
  '       function.

        Dim UserNameW() As Byte
        Dim PasswordW() As Byte
        UserNameW() = lpUserName & Chr(0)
        PasswordW() = lpPassword & Chr(0)

        'To change a network user's password, we neeed to user
USER_INFO_1003 structure.
        Dim Buffer As USER_INFO_1003
        Dim pNewPassWord As Long

        'Allocate memory ans store the new password in a pointer.
        TempHolder = NetApiBufferAllocate(UBound(PasswordW) + 1,
pNewPassWord)
        TempHolder = StrToPtr(pNewPassWord, PasswordW(0))
        Buffer.NewPassWord = pNewPassWord

        'LastError = NetGetDCName(lpServerName:=0&, lpDomainName:=0&,
BuffPtr:=pdc_pointer&)
        '   If LastError <> NERR_Success Then MsgBox "PDC cannot be found.",
vbCritical

        Dim ServerName As String
        Dim ServerNameW() As Byte

        ServerName = zNetGetDCNameAsString()
        ServerNameW = ServerName & vbNullChar

        LastError2 = 0
        LastError = NetUserSetInfo(ServerNameW(0), _
                                   UserNameW(0), _
                                   1003, VarPtr(Buffer), _
                                   LastError2)

        TempHolder = NetApiBufferFree(lpBuf)
        TempHolder = NetApiBufferFree(pNewPassWord)

        zChangeNetworkUserPassword = LastError

  End Function
  '-----------------------------

  Hope this code helps you out.

  Mike

    Hi there,
    I have to make a program to control users' access in a
WindowsTerminalServer
    by enabling and disabling their passwords.
    Is there any API call to change users' password ?

    Thanks for your help,
    Sato

  --
                         \\~ ~//

          ----------o00o-(_)-o00o-------------

  Voice Mail: 375-2066 ext. 3000

  ICQ # 8170125
  ----



Tue, 26 Mar 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to programatically change NT user password?

2. How to change NT user name and password?

3. Change user password in NT

4. How to change NT user name and password?

5. API: Change NT User Password

6. How to change NT user name and password?

7. Validating an NT User's Password

8. checking a user's NT password

9. verify NT user's password in 98

10. LockWorkstation, Change Password and Logoff API's for NT 4.0

11. Change passwords using 'Net Password'

12. VB API to change user's password

 

 
Powered by phpBB® Forum Software