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 8880149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:06:41+00:00 2026-06-14T20:06:41+00:00

i have a project where i need to use the active directory for login

  • 0

i have a project where i need to use the active directory for login to a website made in asp.net, i follow this tutorial….

Active Directory Authentication from ASP .NET

now i want to get the groups of the user, i tried the next code in the default.aspx.vb page but doesn’t work..

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Response.Write("Hello, " + Server.HtmlEncode(User.Identity.Name))

    Dim id As FormsIdentity = CType(User.Identity, FormsIdentity)

    If id IsNot Nothing Then

        Dim ticket As FormsAuthenticationTicket = id.Ticket
        Response.Write("<p/>TicketName: " + ticket.Name)
        Response.Write("<br/>Cookie Path: " + ticket.CookiePath)
        Response.Write("<br/>Ticket Expiration: " + ticket.Expiration.ToString())
        Response.Write("<br/>Expired: " + ticket.Expired.ToString())
        Response.Write("<br/>Persistent: " + ticket.IsPersistent.ToString())
        Response.Write("<br/>IssueDate: " + ticket.IssueDate.ToString())
        Response.Write("<br/>UserData: " + ticket.UserData)
        Response.Write("<br/>Version: " + ticket.Version.ToString())
    End If
End Sub
  • 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-14T20:06:42+00:00Added an answer on June 14, 2026 at 8:06 pm

    I find a better solution, is more easy than any answer that i find on the internet.

    First i create a class to validate if an user is in a group in the active directory:

    Imports System.Security.Principal   
    
    Public Class AutorizationFun
        Dim access As Boolean = False
        Dim id As WindowsIdentity = WindowsIdentity.GetCurrent()
        Public User As WindowsPrincipal = New WindowsPrincipal(id)
    

    Region “Groups Verification”

    'Belongs to sample group
    Private Function inSampleGroup() As Boolean
        Return User.IsInRole("bth0\GG BTUC-SAMPLEGROUP")
    End Function
    Private Function inSampleGroup2() As Boolean
        Return User.IsInRole("bth0\GG BTUC-SAMPLEGROUP2")
    End Function
    

    End Region

    Public Function ProgramsAccsess(ByVal vPage As String) As Boolean
        access = False
    
        Select Case vPage
            Case "~/Sample.aspx"
                If inSampleGroup() Then
                    access = True
                End If
            '---------------------------------------------------------------------
        End Select
        '*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        'access = True
        '*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        Return access
    End Function   
    
    End Class
    

    Then you have to create a function in the code behind of all pages:

    'create var
        Dim ValidateUser As New AutorizationFun
    
        Protected Sub VerifyAccessPage()
            If ValidateUser.ProgramsAccsess(Request.AppRelativeCurrentExecutionFilePath) = False Then
                Response.Redirect("~/DeniedAccess.aspx")
            End If
        End Sub
    

    And to finish to have to use the function in the Page_load event:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            'check whether page is postback or not            
            If Not Page.IsPostBack Then
                VerifyAccessPage()
            End If
        End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to have one project on asp.net mvc 1 but i want to
All our inhouse projects use Active Directory authentication and impersonation as this is the
I have a maven project that contains a certain api I need to use
I need to use IBM Informix for my project where I have point coordinates
Consider this scenario. I have a small enterprise project dev environment. We use archiva
I have an ASP .net C# project using a EntityDataSource with a DevExpress aspxGridView
We have a report designer project which uses Active Reports. We want to use
I am searching for a WebSockets solution for my ASP.NET 4.5 website project that
I have recently been working on a ASP.NET project for a client. The project
The Junits I have in my project need to load property files from the

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.