locked
Windows Authentication RRS feed

  • Question

  • I want to use windows authentication in my vb.net application rather than validating against Database. Is there any possiblitiies or APIs that allows me to use Windows authentication?

    I have user id and passoword text boxes. Once user entered the userid and password, it should validate again Windows authentication.

    Any help would be highly appreciated

     


    Dreaming a world without any war in anywhere
    Thursday, November 18, 2010 7:33 PM

Answers

  • It doesn't quite work that way. You use the My.User to determine if they are already logged in or not in a particular group. That way you let windows handle authentication and your app simply checks to make sure if they are authenticated and at what level of trust.

    Something like this:

    Public Class Form1
    
     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      If Not My.User.IsAuthenticated Then
       MessageBox.Show("Sorry you must be logged to use this program")
       Me.Dispose()
      End If
    
      'or
    
      If My.User.IsInRole(ApplicationServices.BuiltInRole.Guest) Then
       MessageBox.Show("Sorry Guest are not allowed to use this program")
       Me.Dispose()
      End If
     End Sub
    End Class
    

     

    • Proposed as answer by kleinma Thursday, November 18, 2010 8:51 PM
    • Marked as answer by Kee Poppy Thursday, November 25, 2010 10:16 AM
    Thursday, November 18, 2010 8:48 PM