Page 1 of 2 12 LastLast
Results 1 to 40 of 58

Thread: Windows Authentication

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Arrow Windows Authentication

    I'm finally getting around to ASP.NET authentication for a page and its not validating for some reason.

    Here is my code (ASP.NET 1.1).

    VB Code:
    1. Option Explicit On
    2.  
    3. Imports System.Security.Principal
    4. Imports System.Runtime.InteropServices
    5.  
    6. Public Class index3
    7.  
    8.     Inherits System.Web.UI.Page
    9.  
    10.     Declare Function LogonUserA Lib "advapi32.dll" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, ByRef phToken As IntPtr) As Integer
    11.     Declare Auto Function DuplicateToken Lib "advapi32.dll" (ByVal ExistingTokenHandle As IntPtr, ByVal ImpersonationLevel As Integer, ByRef DuplicateTokenHandle As IntPtr) As Integer
    12.     Declare Auto Function RevertToSelf Lib "advapi32.dll" () As Long
    13.     Declare Auto Function CloseHandle Lib "kernel32.dll" (ByVal handle As IntPtr) As Long
    14.  
    15.     Private LOGON32_LOGON_INTERACTIVE As Integer = 2
    16.     Private LOGON32_PROVIDER_DEFAULT As Integer = 0
    17.  
    18.     Private impersonationContext As WindowsImpersonationContext
    19.  
    20.     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    21.         'Put user code to initialize the page here
    22.         'Me.txtUsername.Text = "Domain\Username"
    23.         'Me.txtPassword.Text = String.Empty
    24.     End Sub
    25.  
    26.     Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    27.         If impersonateValidUser(Me.txtUsername.Text, Me.txtPassword.Text) Then
    28.             'MessageBox.Show("User authenticated sucessfully")
    29.             'Insert your code that runs under the security context of a specific user here.
    30.             Response.Redirect("index2.aspx")
    31.             undoImpersonation()
    32.         Else
    33.             'MessageBox.Show("Invalid password or user")
    34.             'Your impersonation failed. Therefore, include a fail-safe mechanism here.
    35.             Response.Redirect("index.aspx")
    36.         End If
    37.     End Sub
    38.  
    39.     Private Function impersonateValidUser(ByVal userName As String, ByVal password As String) As Boolean
    40.  
    41.         Dim tempWindowsIdentity As WindowsIdentity
    42.         Dim token As IntPtr = IntPtr.Zero
    43.         Dim tokenDuplicate As IntPtr = IntPtr.Zero
    44.         Dim ar() As String
    45.         Dim domain As String
    46.         impersonateValidUser = False
    47.         ar = userName.Split("\")
    48.         If UBound(ar) = 0 Then
    49.             CloseHandle(token)
    50.             Exit Function
    51.         Else
    52.             domain = ar(0)
    53.             userName = ar(1)
    54.         End If
    55.         If RevertToSelf() Then
    56.             If LogonUserA(userName, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, token) <> 0 Then
    57.                 If DuplicateToken(token, 2, tokenDuplicate) <> 0 Then
    58.                     tempWindowsIdentity = New WindowsIdentity(tokenDuplicate)
    59.                     impersonationContext = tempWindowsIdentity.Impersonate()
    60.                     If Not impersonationContext Is Nothing Then
    61.                         impersonateValidUser = True
    62.                     End If
    63.                 End If
    64.             End If
    65.         End If
    66.         If Not tokenDuplicate.Equals(IntPtr.Zero) Then
    67.             CloseHandle(tokenDuplicate)
    68.         End If
    69.         If Not token.Equals(IntPtr.Zero) Then
    70.             CloseHandle(token)
    71.         End If
    72.     End Function
    73.  
    74.     Private Sub undoImpersonation()
    75.         impersonationContext.Undo()
    76.     End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Windows Authentication

    What are you trying to do?

  3. #3

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Authenticate users to log in to a web page using Windows auth.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    errr...ASP.NET does this for you automatically.
    No need for all that code at all

    Have:
    Code:
    <authentication mode="Windows" />
    In your config file.
    And then...
    Go into IIS, go to properties of VD, then Directory Security, and untick anonamous access, 1st tick box on form.

    This is all you need.

    Unless of course you want to be a little cleverer.
    I am sure you don't need those API functions there, as I believe .NET can do this in System. blah blah somewhere.

    Woof

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Windows Authentication

    Wow... I've never seen so much code for an existing feature.

    You should google a few articles on "ASP.NET" Windows authentication

  6. #6

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    But I got the code from the link Woka posted a few months ago. Here it is. I'm barely starting on this. I have been busy posting
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Windows Authentication

    Quote Originally Posted by RobDog888
    But I got the code from the link Woka posted a few months ago. Here it is. I'm barely starting on this. I have been busy posting
    That's what you get for listening to him instead of me


    Woka:

    *SLAP*

    Silly badger.

  8. #8
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    when did I post that code?!!! Never seen it in my life before
    U don't need any code for windows auth!
    U ONLY have to make the change in your config file, and the IIS VD properties.
    That's it.
    .NET handles everything else for you.

    Oh I see...u want to write your own login screen. Ahhhhh.

    What benefits are you gonna get from using windows auth? and not forms auth?

    Woka

  9. #9

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Still n00b here for ASP.NET even though the thread was 4 months old.

    I want to create a page with a left "sidebar" or menu that will have two small textboxes for employee login to a different section
    of the site. They dont like the windows popup login.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    OK. no probs, I would want to do exactly the same and write my own login page. Does it have to be windows auth?
    Can you not create your own SQL Server DB with a users tabale?

    Or even more basic...add their names and passwords to the config file. I personally don't like this method.

    I much prefer the SQL method.

    Woka

  11. #11

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    I thought about the SQL method too but I dont like exposing SQL to the internet and having to manage the usernames and passwords.
    The code doesnt error or anything, just doesnt seems to get past the line with "LogonUserA"
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    Have a read of this on the MS web site.

    http://msdn.microsoft.com/library/de...classtopic.asp

    That is what you want isn't it?

    I find Forms Auth much more customisable...Yea you have to add users and stuff, but as for future development and deployment, I think it's the way forward.

    WOka

  13. #13

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Can you tell me more on this "Forms Auth" subject?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    OK. I am writing you 2 demo projects. One uses Forms authentication, and one is a good custom method, which does the same as forms authentication, but it's all done manually.

    Give me about 20mins or so, and I'll post the project.

    WOof

  15. #15
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    Ok here's a quick demo of basic forms authentication.
    The only real code I have coded is in the login page, and the config file.
    In the web.config file I have:
    Code:
        <authentication mode="Forms"> 
            <forms name=".DEMOAPP" loginUrl="Login.aspx" />
        </authentication>
        <authorization>
            <deny users="?" />
        </authorization>
    This means that if the cookie DEMOAPP doesn't exist, or is invalid, then everyone gets redirected to the login.aspx page.

    Maybe you want certain pages that anonamous users, not logging in, can view.
    To do this I have added some extra lines to my config file:
    Code:
    'other config stuff
        </system.web>
    
        'I have added this
        <location path="Main.aspx">
            <system.web>
                <authorization>
    	   <allow users="*" />
                </authorization>
            </system.web>
        </location>
    
    </configuration>
    This basically tells .net that anyone can view Main.aspx, logged in or not.

    I have used the username Woof and password Growl in my exmaples to validate my login.

    My login code looks like:
    VB Code:
    1. Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    2.         Login(txtUsername.Text, txtPassword.Text)
    3.     End Sub
    4.  
    5.     Private Sub Login(ByVal Username As String, ByVal Password As String)
    6.         If ValidateLogin(Username, Password) Then
    7.             System.Web.Security.FormsAuthentication.RedirectFromLoginPage(Username, False)
    8.         End If
    9.     End Sub
    10.  
    11.     Private Function ValidateLogin(ByVal Username As String, ByVal Password As String) As Boolean
    12.         'here you would query your SQL DB as you would with a nomral app
    13.         'but in this case I have hard coded a username and password in.
    14.  
    15.         Return (Username = "Woof") And (Password = "Growl")
    16.     End Function
    The following line is the one that saves the security cookie to the clients PC:
    VB Code:
    1. System.Web.Security.FormsAuthentication.RedirectFromLoginPage(Username, False)
    The username can be got at any time using:
    VB Code:
    1. Response.Write(User.Identity.Name)
    As I have done in my users.aspx page.

    Anyways here's the code.
    Unzip it and create a VD in IIS called FormsAuthenticationDemo2003 and point it at the FormsAuthenticationDemo2003 folder you just extracted.

    That should be it.

    I'll write you a quick manual security app. This uses base pages and requires a little bit more coding, but not much. We use this method at work.

    Woka
    Attached Files Attached Files

  16. #16

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Thanks Badger, but I can keep unauthenticated viewers from viewing certain pages?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #17
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    Yea...try and view the Users.aspx page without loggin in.
    Try adding more pages to your project. WebForm1,2,3...blah.
    Now run your project. They are ALL protected from users who are not logged in.
    If you want a page to be viewed by someone who is not logged in then you need to add that page to the config file like I did with Users.aspx

    It blocks all pages unless you explicitly state otherwsie.

    Woof

  18. #18
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    OK, here's my 2nd demo. This uses custom authentication, so I leave the default web.config file as it is.

    Unzip the code from the zip file, and create a VD in IIS called CustomAuthenticationDemo2003, which points at the dir you just unzipped.

    This example uses cookies again, but this time we manually set them up. This gives you a little more contol as you can add time out limits.

    All pages inherit my base page, which is:
    VB Code:
    1. Public Class MyBasePage
    2.     Inherits System.Web.UI.Page
    3.  
    4.     Public Sub ValidateLogin()
    5.         Dim Cookie As HttpCookie = Request.Cookies.Item("SECURITY")
    6.         If Cookie Is Nothing Then
    7.             Dim RedirectPage As String = Page.ToString.Substring(4).Replace("_", ".")
    8.             Response.Redirect("Login.aspx?Redirect=" & RedirectPage)
    9.         End If
    10.     End Sub
    11.  
    12.     Public ReadOnly Property Username() As String
    13.         Get
    14.             Dim Cookie As HttpCookie = Request.Cookies.Item("SECURITY")
    15.             If Not (Cookie Is Nothing) Then
    16.                 Return Cookie.Values.Item("USERNAME")
    17.             End If
    18.         End Get
    19.     End Property
    So in your web site your pages inherit MyBaseClass.
    If in the Page Load event of a form if you want to secure it from unauthorised users just add:
    VB Code:
    1. MyBase.ValidateLogin()
    As you can see from the above base page code that if the cookie doesn't exist then you get redirected to the login page. I have added a little bit of code in there for a redirect once you have logged in. This is very rough code and has some problems, ie it doesn't cater for querystrings, but it's only for an example anyways.

    In the login.aspx page we have the login code:
    VB Code:
    1. Private Sub Login(ByVal Username As String, ByVal Password As String)
    2.         If ValidateLogin(Username, Password) Then
    3.             Dim Cookie As New HttpCookie("SECURITY")
    4.             Cookie.Values.Add("USERNAME", Username)
    5.             Response.Cookies.Add(Cookie)
    6.             Dim RedirectPage As String = Request.QueryString.Item("Redirect")
    7.             If RedirectPage = String.Empty Then
    8.                 RedirectPage = "Main.aspx"
    9.             End If
    10.             Response.Redirect(RedirectPage)
    11.         End If
    12.     End Sub
    As you can see if the login is validated then a new cookie is created that stores the username. This is a session based cookie.

    This where it's slightly better at Forms Auth as we can now add a timeout period onto the site.
    So say if our user didn't access the site for say 20 minutes, we would want their session to timeout. This can be done by adding:
    VB Code:
    1. Cookie.Expires = Date.Now.AddMinutes(20)
    just after you've decalred it.

    One good thing about this method is that it can be easily changed. Maybe u don't want to use cookies. Maybe you want to use SQL server and store session GUIDs, which is what we do at work. Personally I prefer the cookie method. Bu the SQL sevrer way does have it's advantages.

    Woka
    Attached Files Attached Files

  19. #19
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    Just to add a little extra bit of code I decided to change the validate login function in both examples to show you how to connect and validate from an SQL db.
    Just replace the function with:
    VB Code:
    1. Private Function ValidateLogin(ByVal Username As String, ByVal Password As String) As Boolean
    2.         Dim Conn As New SqlClient.SqlConnection("Your connection string here")
    3.         Dim SQL As String
    4.  
    5.         SQL = "SELECT Password "
    6.         SQL &= "FROM Users "
    7.         SQL &= "WHERE Username = @Username "
    8.  
    9.         Dim Comm As New SqlClient.SqlCommand(SQL, Conn)
    10.         Dim Param As New SqlClient.SqlParameter("@Username", SqlDbType.VarChar)
    11.         Param.Direction = ParameterDirection.Input
    12.         Param.Value = Username
    13.  
    14.         Comm.Parameters.Add(Param)
    15.  
    16.         Dim da As New SqlClient.SqlDataAdapter(Comm)
    17.         Dim dt As New DataTable
    18.  
    19.         da.Fill(dt)
    20.  
    21.         Conn.Close()
    22.         Conn.Dispose()
    23.  
    24.         Dim Validated As Boolean
    25.  
    26.         If dt.Rows.Count > 0 Then
    27.             Validated = (dt.Rows.Item(0).Item("Password").ToString = Password)
    28.         End If
    29.  
    30.         Return Validated
    31.     End Function
    Added password encryption may be a good idea, but I left this out to keep the example basic.

    Woof

  20. #20

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Thanks allot Badger. This should keep me busy for another 4 months
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  21. #21
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    One of the small problems with the latter example is that the cookie lasts 20 minutes. OK, yea this good, it's what we want. But what we don't want is for them to close IE down walk away from their computer and then someone else browsing to the site, and oh great, the cookie still lets them in. Doh!

    This can be achieved by added a value to the session state.
    In the Global.asax file I have:
    VB Code:
    1. Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
    2.         Session.Item("VALIDATED") = False
    3.     End Sub
    So, when someone opens a new session, and browses to the site, the session varible "VALIDATED" gets set to False.

    So when someone logs in I want to set this to True.
    I do this by doing the following in the login function in Login.aspx:
    VB Code:
    1. 'rest of code
    2. End If
    3.  
    4. Session.Item("VALIDATED") = True 'I added this line
    5.  
    6. Response.Redirect(RedirectPage)
    7. 'rest of code
    Now in our base class we need to check for this. So I changed the ValidateLogin function to:
    VB Code:
    1. Public Sub ValidateLogin()
    2.         Dim Cookie As HttpCookie = Request.Cookies.Item("SECURITY")
    3.         Dim Validated As Boolean
    4.         If Not (Cookie Is Nothing) Then
    5.             Validated = CType(Session.Item("VALIDATED"), Boolean)
    6.         End If
    7.         If Not Validated Then
    8.             Dim RedirectPage As String = Page.ToString.Substring(4).Replace("_", ".")
    9.             Response.Redirect("Login.aspx?Redirect=" & RedirectPage)
    10.         End If
    11.     End Sub
    This now checks for the session varible.

    I have no idea if this is the correct way to go about this or not, but it works, so I am happy for now.

    Please find the project attached.

    WOka
    Attached Files Attached Files

  22. #22

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Thanks Badger. I got the latest and greatest now so I will go over both of them tonight from home.
    I'll post more questions as this is allot to take in for an ASP.NET n00b like me.

    Ruff!
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  23. #23
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    Here's the next installment

    I have changed the Validate login function in the MyBaseClass class.
    This change now handles redirects with query strings.
    The code is:
    VB Code:
    1. If Not Validated Then
    2.             Dim Query As String = String.Empty
    3.             For Index As Integer = 0 To Request.QueryString.Count - 1
    4.                 If Query.Length > 0 Then
    5.                     Query &= "&"
    6.                 End If
    7.                 Query &= Request.QueryString.Keys.Item(Index)
    8.                 Query &= "="
    9.                 Query &= Request.QueryString.Item(Index)
    10.             Next Index
    11.  
    12.             Dim RedirectPage As String = Page.ToString.Substring(4).Replace("_", ".")
    13.  
    14.             If Query.Length > 0 Then
    15.                 RedirectPage &= "?" & Query
    16.             End If
    17.             RedirectPage = Server.UrlEncode(RedirectPage)
    18.             Response.Redirect("Login.aspx?Redirect=" & RedirectPage)
    19.         End If
    I also added Server.Decode in the Login page to decode the "redirect" query string. I had to encode it because you cannot have a query string in a query string as it would look like:
    Code:
    ?Redirect=Users.aspx?ID=5&Task=Delete
    ASP.NET would read this as 3 different query strings, the 1st being "Users.aspx?". For this reason we have to URL encode it.

    Again, I am not sure if this is the correct way to get the query string, but I don't know of any simpler way to get it

    Attached is the new updated project.

    Wooof
    Attached Files Attached Files

  24. #24
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    OK...I've changed it again.
    It now, instead of forcing you to the login page, gives you the option to force to a login page.
    The base class has changed to:
    VB Code:
    1. Public Function ValidateLogin(ByVal ForceLogin As Boolean) As Boolean
    2.         Dim Cookie As HttpCookie = Request.Cookies.Item("SECURITY")
    3.         Dim Validated As Boolean
    4.         If Not (Cookie Is Nothing) Then
    5.             Validated = CType(Session.Item("VALIDATED"), Boolean)
    6.         End If
    7.         If Not Validated And ForceLogin Then
    8.             Login()
    9.         Else
    10.             Return Validated
    11.         End If
    12.     End Function
    13.  
    14.     Public Sub Login()
    15.         Response.Redirect("Login.aspx?Redirect=" & Server.UrlEncode(CurrentURL))
    16.     End Sub
    17.  
    18.     Public ReadOnly Property CurrentURL() As String
    19.         Get
    20.             Return Request.Url.PathAndQuery
    21.         End Get
    22.     End Property
    This means I can do the following in my main pages:
    VB Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         If MyBase.ValidateLogin(False) Then
    3.             btnLogin.Visible = False
    4.             Response.Write("Hello " & MyBase.Username & ", your task today is " & MyBase.GetQueryString("Task", "***Unknown***"))
    5.         Else
    6.             btnLogin.Visible = True
    7.         End If
    8.     End Sub
    9.  
    10.     Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    11.         MyBase.Login()
    12.     End Sub
    The above code is only an example. Maybe you want someone to view pages regardless of if they are logged in or not, but if they arn't you want to disable functionality, or show them a different control.
    You can still force a login by doing:
    VB Code:
    1. MyBase.ValidateLogin(True)
    I have also added some querystring functions to the base class to help my pages retieve the correct querystring in the correct format.

    The code attached contains the new changes.

    Woof
    Attached Files Attached Files

  25. #25

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Just finished dinner Badger. I see you have been busy again I am checking it out now.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  26. #26

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Booooo! *SLAP*

    Error on the users page in the custom authentication sln:
    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  27. #27

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Fixed it so now on to the new part.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  28. #28

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Hey BadgerBoy, I got the original code working and wanted to know if I could merge the two logics together? Authenticate via
    Windows and then use either cookies or a session variable to allow the user to view certain pages? Would the cookie logic be less
    secure? I think it may be but I want your opinion.

    If we were to use session vars is that also secure enough or what would I have to do?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  29. #29
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    Session varibles are more secure as the client has no access to them.
    But cookies can be encrypted so they are secure.
    At work we store a simple UID in the cookie, and validate this against a table in a DB.
    Table is something like:

    • GUID
      UserID
      LastActiveDate

    So you query the table for the row with the GUID, then validate the last active to see if they ain't timed out.
    Alternatively you can encrypt the data in a cookie.
    I like the idea of cookies.

    I am not sure if you can merge the 2 authentication methods together
    U may be able to validate a users domian login with some funky system namespace or some APIs.

    I'll look into this for you.

    woof

  30. #30
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    since you would use the same code as in my last example...all you need to do is fine ANY .NET code that can validate a users domian login. I know there are API's in VB6...so there must be something in .NET

    Woof

  31. #31

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Actually the original code I posted is working for me somehow now. So thats why I was thinking that if they validate I can
    create a session var of LoggedIn or something and have it timeout after 15 mins. Then when they navigate between pages it will
    not need to validate to the db with another call but only verify the session var.

    Does this sound like good logic?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  32. #32
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    Could you not use the impersonateValidUser function inside my validate function?

    My code does not make a call to the DB, but our app at work does because we cannot use cookies, when you refresh a page. Well it does, but only the 1st time, then it creates a session var and a cookie. Just like yours will only validate the users Windows login.
    Just replace MY DB code in ValidateUser, I think that's what I called the function, with code from your original post, mainly the impersonateValidUser function.

    Make sense?

    Going bed now...zzzzzzzzzz

    Woof

  33. #33

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Yes, its starting to sink in, but only a shallow transversal.

    I dont know how to use session vars only that they do exist. I'll take a crack at it tonight when I get home. If I get it I will post an update.

    Thanks and it looks like your Badger is frollicking in the snow now.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  34. #34
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    Canton, GA
    Posts
    487

    Re: Windows Authentication

    Where were you 3 months ago WOK... You need to turn this into a tutorial - I looked all over the net for answers you gave in this post... matter of fact I tried learning asp.net a year ago but the lack of your example like this ran me screaming back to asp.

    Good Job, Bravo...

    Anjari

  35. #35

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Yes the Badger is a lifesaver

    Sorry BadgerBoy I didnt finish it. Just thought I would let you know since I'm going to bed and your just waking up :.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  36. #36
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    OK. here's the next version.
    I have it validating a domian user's password.
    This code does not impersonate a windows user, I removed that code to make it a little more simple.
    All it does is validates the domain users password...I believe. I am still trying to look up more info on the API function:
    VB Code:
    1. Private Declare Function LogonUserA Lib "advapi32.dll" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, ByRef phToken As IntPtr) As Integer

    I have moved all the user validation code to a class called Authorisation, just to keep the code neat and in one place. I have also added an enum:
    VB Code:
    1. Public Enum LoginMode
    2.         Database = 0
    3.         HardCoded = 1
    4.         Windows = 2
    5.     End Enum
    Which is used when calling the ValidateUser method in the Authentication class, the ValidateUser function is:
    VB Code:
    1. Public Function ValidateLogin(ByVal Username As String, ByVal Password As String, ByVal AuthenticationMethod As LoginMode) As Boolean
    2.         Select Case AuthenticationMethod
    3.             Case LoginMode.Database
    4.                 Return ValidateDBLogin(Username, Password)
    5.             Case LoginMode.HardCoded
    6.                 Return ValidateHardCodedLogin(Username, Password)
    7.             Case LoginMode.Windows
    8.                 If Username.IndexOf("\") > 0 Then
    9.                     Dim LoginDetails() As String = Username.Split("\"c)
    10.                     Return ValidateWindowsLogin(LoginDetails(0), LoginDetails(1), Password)
    11.                 End If
    12.         End Select
    13.     End Function
    I have prely done this enum for this demo. In the real world you would just pick one of those methods and ignore the rest.

    When logging into a domain your username must be in the format DOMAIN\Username.
    This then gets split up into it's individual bits when sent to the ValidateWindowsLogin function.

    RobDog, I know you wanted this as a way to login, but do you want to impersonate a user, so that you can get access to resources on say the network etc...? I personally can't see the need for this and would find it pointless for what I want to do with my intranet...not sure about you.

    To change the method of authentication go into the Login.aspx page and change the Login function to pass a different enum to the authentication class.

    Woka
    Attached Files Attached Files

  37. #37
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    Quote Originally Posted by Anjari
    Where were you 3 months ago WOK... You need to turn this into a tutorial - I looked all over the net for answers you gave in this post... matter of fact I tried learning asp.net a year ago but the lack of your example like this ran me screaming back to asp.

    Good Job, Bravo...

    Anjari
    Thanks very much



    I was the same about a year ago...came looked around, couldn't find anything...gave up
    The thing is that it doesn't take long to knock up a small example like this. More people should do it.

    Woof

  38. #38
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    Thanks to Alex_Read and Matt3011 for there help with this.
    For authenticating a login against an active directory you can use:
    VB Code:
    1. Private Function ValidateActiveDirectoryLogin(ByVal Domain As String, ByVal Username As String, ByVal Password As String) As Boolean
    2.  
    3.         Dim Success As Boolean = False
    4.  
    5.         Dim Entry As New System.DirectoryServices.DirectoryEntry("LDAP://" & Domain, Username, Password)
    6.         Dim Searcher As New System.DirectoryServices.DirectorySearcher(Entry)
    7.         Searcher.SearchScope = DirectoryServices.SearchScope.OneLevel
    8.         Try
    9.             Dim Results As System.DirectoryServices.SearchResult = Searcher.FindOne
    10.             Success = Not (Results Is Nothing)
    11.         Catch
    12.             Success = False
    13.         End Try
    14.  
    15.         Return Success
    16.  
    17.     End Function
    You have to reference the System.DirectorySevices in your application.
    OK...I have now removed the old code that authenticated a windows account and replaced it with the above code.

    I have attached the full updated project to this post.

    Woof
    Attached Files Attached Files

  39. #39

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Windows Authentication

    Possibly, since I may want to do some custom stuff with Exchange and Outlook. I will need the users to be authenticated before
    they get to that point and I will also be taking this info and using it to retrieve the Exchange data.

    Thanks for the updates! We are running AD here and I am running it at home too so its all good.

    Best not to do windows authentication for security reasons?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  40. #40
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: Windows Authentication

    Quote Originally Posted by RobDog888
    Best not to do windows authentication for security reasons?
    Errrr....why?

    I think you can still communicate with exchange etc even if you are not impersonating a windows user. So long as you have the domain, username and password you should be fine.

    Woof

Page 1 of 2 12 LastLast

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