[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

07/28/2000 at 09:36AM PDT, ID: 10843501
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Using Window NT Authentication

Asked by doug_barnard44 in Visual Basic Programming

Tags: wnetenumcachedpasswords, password_cache_entry

I am trying to retrieve a Windows NT user's password to use it for verifying a SQL Server login.  I have the code that accesses the API, but it is not executing the callback function that actullay retrievs the info.

Here is th code....


'***********************************************
'* Function to Get The UserName From Windows NT (in my form)
'***********************************************

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

'******************
'* Code in my form
'*****************

'Get the Password from Windows NT
                    Dim i As Integer
                    Dim s As String
                    Dim l As Long
                    Dim b As Byte
   
                    b = &HFF
                    i = 0
                    l = 0
                    s = ""
                   
                    '?????????????why does this not execute the callback function?????????????
                    Call WNetEnumCachedPasswords(s, i, b, AddressOf callback, l)
                    txtPassword.Text = goConnect.NTPassword
 
                    'connect to SQL Server
                    If SQLTestConnection Then
                        MsgBox "Test Connection to SQL Server Successful", vbInformation, Me.Caption
     
                        'display the table list frame
                        Call FormToggle
                        fraSQLServer.Visible = False
         
                        'load the grid with table names (if not already)
                        If lstTables.ListCount = 0 Then
                            For intIndex = 0 To goConnect.TableCount - 1
                                lstTables.AddItem (goConnect.TableNames(intIndex, 0))
                            Next intIndex
                        End If
                    End If


'*************************
'* Code From a BAS Module
'*************************

'******************************
'* Gets the User's NT Password
'******************************

'undocumented function in mpr.dll
Declare Function WNetEnumCachedPasswords Lib "mpr.dll" (ByVal s As String, ByVal i As Integer, ByVal b As Byte, ByVal proc As Long, ByVal l As Long) As Long


'purpose:   to parse the .PWL file of the currently logged on user
'platform:  win '95 (ms networking, password caching enabled)
'language:  vb 5.0 sp2
'author:    todd harmon <tharmon@gyver.com>
'date:      9/16/1998
'comments:  the mpr.dll has many functions that are poorly documented,
'           this is my attemped at unraveling one of those functions
'           for visual basic programmers
'
'this sample program is provided "as is"!
'use at your own risk!

'comments/questions are welcome, see e-mail address above


'this structure is returned by the call to WNetEnumCachedPasswords
Type PASSWORD_CACHE_ENTRY
   
    cbEntry As Integer              'size of this returned structure in bytes
    cbResource As Integer           'size of the resource string, in bytes
    cbPassword As Integer           'size of the password string, in bytes
    iEntry As Byte                  'entry position in PWL file
    nType As Byte                   'type of entry
    abResource(1 To 1024) As Byte   'buffer to hold resource string, followed by password string
                                    'should this be bigger?

End Type



Public Function callback(x As PASSWORD_CACHE_ENTRY, ByVal lSomething As Long) As Integer
'callback routine for WNetEnumCachedPasswords results
Dim i As Integer
Dim s As String

    s = "Type: " & x.nType
    '1 = domains?
    '4 = mail/mapi clients?
    '6 = RAS entries?
    '19 = iexplorer entries?
   
    s = s & "     Rsrc: "
    For i = 1 To x.cbResource
        If x.abResource(i) <> 0 Then 'nulls don't display nicely
            s = s & Chr(x.abResource(i))
        Else
            s = s & " "
        End If
    Next i
   
    s = s & "     Pwd: "
   
    For i = x.cbResource + 1 To (x.cbResource + x.cbPassword)
        If x.abResource(i) <> 0 Then 'nulls don't display nicely
            s = s & Chr(x.abResource(i))
        Else
            s = s & " "
        End If
    Next i
   
    goConnect.NTPassword = s
   
    callback = True
End Function

[+][-]07/28/00 09:38 AM, ID: 3649023

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/28/00 12:31 PM, ID: 3654353

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/28/00 01:26 PM, ID: 3654875

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/01/00 08:55 AM, ID: 3703861

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Basic Programming
Tags: wnetenumcachedpasswords, password_cache_entry
Sign Up Now!
Solution Provided By: doug_barnard44
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08/01/00 04:47 PM, ID: 3712856

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/01/00 04:47 PM, ID: 3712857

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/01/00 04:48 PM, ID: 3712858

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91