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

  • SEARCH
  • Home
  • 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 8982059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:29:29+00:00 2026-06-15T20:29:29+00:00

I have followed a tutorial to implement LDAP (Active Directory) authentication to an ASP.NET/C#

  • 0

I have followed a tutorial to implement LDAP (Active Directory) authentication to an ASP.NET/C# 4.0 Web Application. I have the authentication working, and am able to log in under a user of our domain. The next step however is not covered in this tutorial, where I need to keep a session-specific object with some variable data.

Now that I have LDAP authentication working, I’m making a class to wrap the session. However, I’m not sure how I can create this session in a way that it will stay active through all this user’s requests. In Globals.asax, I have utilized Application_AuthenticateRequest as required in the tutorial. I’m assuming there’s something I need to do here, but since I’m new to C# (more familiar with Delphi), I don’t know where I need to actually declare/create this user class instance.

This class contains some things I’d like to keep accessible throughout this user’s session, assuming of course the server will stay running throughout this time. For example, a dataset containing product data, which the user may request various parts of this same dataset in different requests. Therefore, it must stay accessible throughout the entire user’s session, not just that single HTTP request.

  • 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-15T20:29:31+00:00Added an answer on June 15, 2026 at 8:29 pm

    I think you should have a look at Forms authentication for asp.net.

    Web.config:

    <authentication mode="Forms">
        <forms name=".ASPXFORMSAUTH" loginUrl="/Login.aspx" timeout="120" />
    </authentication>
    <authorization>
        <deny users="?" />
    </authorization>
    

    After you have managed to log in your visitor using ldap you can log in that visitor in your web-application with very little code:

    PrincipalInfo.CurrentPrincipal = PrincipalInfo.CreatePrincipal(userName);
    FormsAuthentication.SetAuthCookie(userName, true);
    

    I would also give you an advice about using Session. Jeffery gives you a simple example of how to use the Session object. But don’t go store multiple single values in Session; instead create a class like ‘VisitorInformation’ with all properties you will need. And then make a static manager that sets and gets that visitor information.

    Visitor visitor = VisitorManager.CurrentVisitor;
    string name = visitor.Name;
    int age = visitor.Age;
    
    
    
    
    private const visitorSessionKey = "visitorSessionkey";
    public static Visitor CurrentVisitor
    {
        { 
             get { return (Visitor)Session[visitorSessionKey] ?? new Visitor(); }
        }
    }
    

    This way you won’t sprinkle your code with calls to session all over the place, with the increasing risk of spelling a key wrong or getting values out of sync.

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

Sidebar

Related Questions

Hi have followed this tutorial using Core plot framework http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application My project compiles, but
I have followed a tutorial to create a simple blog writing application in PHP
I have followed this great tutorial and I finally managed to implement a 3
I have followed this tutorial to create the first azure application http://msdn.microsoft.com/en-us/WAZPlatformTrainingCourse_IntroToWindowsAzureLabVS2010 Because after
To implement database access in my application I followed Lars Vogel tutorial , but
I have followed this tutorial for building my chat application. When I try to
hello all its my first application using Zend Framework i have followed tutorial it
I am newbie for iPhone application. I have followed this tutorial for login from
I have followed a tutorial on how to use the youtube gdata. Populating a
I have followed the tutorial for getting a Thunderbird extention going and succeeded in

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.