Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

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

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,
  • 3
  • 2
1 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.


inverted_2000Author Commented:
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,
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.
inverted_2000Author Commented:
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.
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

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now