Results 1 to 5 of 5

Thread: NT Authentication

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210

    NT Authentication

    Anybody knows how can i make NT Authentication in VB.NET??



    Thanks a lot!
    Guilherme Costa

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What do you mean? The OS does the authing but you can check the current user, is that what you mean?
    VB Code:
    1. Dim wp As New Security.Principal.WindowsPrincipal(Security.Principal.WindowsIdentity.GetCurrent)
    2.         If wp.IsInRole("Administrator") Then MsgBox(String.Format("{0} is an Admin", wp.Identity.Name))

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210
    i meant this:

    VB Code:
    1. Const LOGON32_LOGON_INTERACTIVE As Long = 2
    2.     Const LOGON32_LOGON_NETWORK As Long = 3
    3.     Const LOGON32_PROVIDER_DEFAULT As Long = 0
    4.     Const LOGON32_PROVIDER_WINNT50 As Long = 3
    5.     Const LOGON32_PROVIDER_WINNT40 As Long = 2
    6.     Const LOGON32_PROVIDER_WINNT35 As Long = 1
    7.  
    8.  
    9.     Private Declare Function LogonUser Lib "advapi32.dll" Alias "LogonUserA" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Long, ByVal dwLogonProvider As Long, ByVal phToken As Long) As Long
    10.  
    11.  
    12.     Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click
    13.  
    14.         Dim htoken As Long
    15.  
    16.         Dim returnValue As Boolean
    17.         returnValue = LogonUser(TextBox1.Text, "mechsys", TextBox2.Text, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_WINNT50, htoken)
    18.         If returnValue = True Then
    19.             MsgBox("Logged")
    20.         Else
    21.             MsgBox("Not logged")
    22.         End If
    23.  
    24.  
    25.  
    26.     End Sub

    but this code always return True, even when i put an unknown user or password!

    I need to put an authentication form on my application, because the employees register their worked hours on the software, so i need to do this authentication!!

    Thanks a lot,
    Guilherme Costa

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Aren't they already logged into the computer using that same information? If so then you can get their username or info and groups or what not from the WindowsPrincipal or WindowsIdentity objects. Then they also don't have to log in twice (which I personally always found annoying). Otherwise I'd search this forum or google for a .NET version of the API way. I know it has come up before but don't recall the answer off the top fo my head.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210
    yes, the porpose is to log twice, because we could put an computer just to they log and register the time!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width