Anybody knows how can i make NT Authentication in VB.NET??
Thanks a lot!
Guilherme Costa
Printable View
Anybody knows how can i make NT Authentication in VB.NET??
Thanks a lot!
Guilherme Costa
What do you mean? The OS does the authing but you can check the current user, is that what you mean?
VB Code:
Dim wp As New Security.Principal.WindowsPrincipal(Security.Principal.WindowsIdentity.GetCurrent) If wp.IsInRole("Administrator") Then MsgBox(String.Format("{0} is an Admin", wp.Identity.Name))
i meant this:
VB Code:
Const LOGON32_LOGON_INTERACTIVE As Long = 2 Const LOGON32_LOGON_NETWORK As Long = 3 Const LOGON32_PROVIDER_DEFAULT As Long = 0 Const LOGON32_PROVIDER_WINNT50 As Long = 3 Const LOGON32_PROVIDER_WINNT40 As Long = 2 Const LOGON32_PROVIDER_WINNT35 As Long = 1 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 Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click Dim htoken As Long Dim returnValue As Boolean returnValue = LogonUser(TextBox1.Text, "mechsys", TextBox2.Text, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_WINNT50, htoken) If returnValue = True Then MsgBox("Logged") Else MsgBox("Not logged") End If 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
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.
yes, the porpose is to log twice, because we could put an computer just to they log and register the time!