Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8595787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:31:22+00:00 2026-06-12T00:31:22+00:00

I have a C# web application that (in some configurations) allows the user to

  • 0

I have a C# web application that (in some configurations) allows the user to enter Windows credentials which it then uses to authenticate to a remote service. To accomplish this, we currently call LogonUser and use the resulting token to create a WindowsIdentity, which we then impersonate. It’s been working fine with no real problem.

Recently I was reading about web authentication and read that for basic authentication IIS uses LsaLogonUser to create the impersonation context. I kind of understand the difference between the two and it kind of sounds like we should be using LsaLogonUser, but I hate to make changes I don’t understand for an unclear benefit. On the other hand, the guys who work on IIS understand the Windows API better than I do.

So: Which function is more appropriate for a web application? Would you say it’s wrong to use LogonUser and why? Are there situations (network configuration, user permissions, etc) where one will work and the other won’t? Is it any kind of security risk to use LogonUser?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:31:23+00:00Added an answer on June 12, 2026 at 12:31 am

    There are many questions in your question, here is a quick answer for all of them, followed by some details.

    1. A web application in .Net should use LogonUser. Here is a Microsoft Knowledge base article with sample code.
    2. It is okay to use LogonUser, there is nothing wrong with it. It is the function you should use most of the time.
    3. LogonUser does not support Kerberos Services 4 User (S4U), but LsaLogonUser does. On a more historical note, LogonUser used to require TCB privilege, but not anymore (except for Passport logons). There was a clever way around it anyway (look for “Another use for SSPI in that page).
    4. The same risk apply to both function : you must not spill the passwords in error messages, or logs, etc. But LsaLogonUser can get an token without a password, which makes it safer in specific circumstances.

    Now some details on answer 2, 3 and 4

    It’s okay to use LogonUser

    You should use LogonUser over LsaLogonUser if it supports your use case. Most of the time, it does, so you use LogonUser. LsaLogonUser works, but it has a lot of parameters, some are pointers to memory that must be in a specific format. In other words, LsaLogonUser was made by C developpers when packed structures and self relative pointers where… I don’t know. Cool ?

    LsaLogonUser can give you a token without a password (S4U)

    In Windows Server 2003 was introduced Kerberos Services for User (S4U). S4U allows you to call a KDC and get a token for a user, without providing a password. That token is a Identify token, it cannot be used to impersonate the user. LogonUser cannot give you that token but LsaLogonUser can.

    Keith Brown explains what is S4U and how to use it better than I ever could.

    In conclusion

    There is only one use case were LsaLogonUser is better than LogonUser. But since WindowsIdentity provides a constructor for that (S4U), I don’t see why one would ever use LsaLogonUser in a .Net application.

    Your code is good as it is 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that allows users to enter search criteria and the
We have a web application that is generating some 3-5 parallel threads every five
I have a web application that I want to run some system tests on,
I have a web application that will be doing some processing with submitted data.
I have a web application on ASP.NET (C#) that has some precompiled components. I've
I have a web application build on PHP that (does some processing and) displays
We have built a web application that accepts SOAP messages, does some processing, calls
I have a web application where the masterPage/template contains some static HTML that never
I have a C# web forms ASP.NET 4.0 web application that uses Routing for
I have a web application that uses a local SQL Server Express database (a.k.a.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.