ASP.NET session variables based on AD account group memberships.

Posted on 2007-08-09
Last Modified: 2013-11-26
Hey everyone,

I'm getting back into the programming circle and I'm looking for way with the .NET framwork to authenticate session variables with users Active Direcotry accounts.

I'm really looking to break up HR and Payroll session variables based on their AD group membership.

The forms are ASP.NET....I don't know if C# integrates with the ASP style forms or not...if you can please also clarify that for me.

I appreciate it sooooo much.

Thanks guys,
Question by:inverted_2000
    LVL 9

    Accepted Solution

    The subject is pretty broad but I think I can point you in the right direction.  The .NET Framework does have the capability to work directly with Active Directory through the Active Directory Services.  This is going to be independent of which language you use, for instance, you can use VB .NET, C# .NET, etc.  

    Now, the difficult part is going to be interacting with your classic ASP Pages as your ASP Pages and your ASP .NET pages won't share the same Session State.  .NET can store Session State in a couple of different ways:  In Process (default), in a separate database which also helps to support clustering / load balancing across multiple web servers with a single state server, and customer implementation (you basically roll your own).

    The session information would have to be passed in some way to the ASP .NET pages in order to access those values and query active directory.  You could do this by posting the values to a .NET page or by creating / utilizing a .NET Web Service and posting / retrieving the information that way.

    More information on working with Active Directory can be found here:

    As far as Authentication, you can set ASP .NET up to do Windows Authentication with Active Directory and even create custom providers to accomplish more complex AD tasks.

    The following article should get you started on Forms Authentication:

    and the following MSDN Article discusses Forms Authentication with Active Directory in .NET 2.0.


    LVL 2

    Author Comment

    Thanks Dustin,

    that all really helps a lot.  I'd like to clear up one more thing if you might do so for me.

    ASP.NET is either C# or VBScript.?.?.?  Is that correct?

    And the legacy ASP used either JavaScript or VBScript.?.?.?

    The form controls...for instance:
    <asp:TextBox ID="txt_ForExample" runat="server" />

    are the ASP part of ASP.NET...but the true interaction between the server and the client is done with either C# or VBScript?

    Thanks a lot again,
    LVL 9

    Expert Comment

    This is correct.  There are actually several different languages (J# as well).  You can also obtain interpreters for other languages I believe, but here's what happens:

    You code in C#, VB .NET, J#, your choosing.  You may precompile the application or the Framework will compile it for you when the pages are hit on the server.  No matter which language you choose, the compiler will compile it into the same common language (MSIL) which is actually what gets executed by the framework.

    In fact, if you're an ASP developer, you will find VB .NET much easier to pick up quickly as it's syntactically very similar.  There are just a few things to check the syntax of.

    In ASP, to check the length of a trimmed contents of a textbox called "FirstName" you would use:
    Dim x, strName
    strName = Request.Form("FirstName")
    x = Len(Trim(somestring))

    In VB .NET you can actually use hte same syntax but you can also do this:
    your textbox:  <asp:TextBox id="FirstName" runat="server" />

    and in your code:
    Dim x As Integer

    x = FirstName.Text.Trim.Length

    The string functions are executed in order, so it allows you serverside access to the contents of the textbox using the same functions.
    x = Len(Trim(FirstName.Text)) is also valid, but FirstName.Text.Trim.Length is a bit more OO looking.

    Hope this clears things up a bit!  If there's anything else you want me to elaborate on, feel free to ask.
    LVL 2

    Author Comment

    Thanks a million because you have cleared up a lot for me&I wish I could buy you lunch at least cause Ive been wanting to confirm these questions for a long time.  
    Ive got all of these books on my shelf&ASP.NET, VB.NET etc&.but Ive been a systems admin for the past few years and was a ColdFusion programmer in the past.
    Ive got a new job opportunity to be 50/50 systems admin / programmer and I want to start programming again and I needed to clear these things up first so at least I look like I know what Im doing (o:
    Anywho& thanks a million.  You help is priceless.
    LVL 9

    Expert Comment

    Thanks!  :)  If you're getting back into it and want a great book, I very highly recommend ASP .NET 2.0 Unleashed by Stephen Walther:

    I bought it for myself as it is one of the few .NET books that concentrate only on web development.  The book samples are all in VB but it also includes all samples in C# on the accompanying CD.  It's a great read and does an excellent job of explaining things as it goes as well as providing samples that can be used in the real world.  A great read!   800+ pages with a good Appendix / Index.



    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now