Click here to Skip to main content
15,885,278 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: asp.net 2010 code compare Pin
dcof4-Jul-12 14:45
dcof4-Jul-12 14:45 
Generalmasterpages Pin
jkirkerx5-Jul-12 7:08
professionaljkirkerx5-Jul-12 7:08 
GeneralRe: asp.net 2010 code compare Pin
R. Giskard Reventlov3-Jul-12 16:35
R. Giskard Reventlov3-Jul-12 16:35 
GeneralRe: asp.net 2010 code compare Pin
BillWoodruff5-Jul-12 13:41
professionalBillWoodruff5-Jul-12 13:41 
GeneralRe: asp.net 2010 code compare Pin
jkirkerx6-Jul-12 6:58
professionaljkirkerx6-Jul-12 6:58 
Questioncreate website like blogigo Pin
marjan_gh3-Jul-12 9:04
marjan_gh3-Jul-12 9:04 
AnswerTry DotNetNuke Pin
David Mujica3-Jul-12 10:38
David Mujica3-Jul-12 10:38 
QuestionLogin problem Pin
serigraphie3-Jul-12 6:35
serigraphie3-Jul-12 6:35 
VB

VB

CSS
Hi Everyone,
Good evening. Can you help me point out what seems to be the problem with my applciation? I know my problem will be a piece of cake to you guys.

I have a login page where the user will input his username and password:

here is the code:


VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
            Try
                status = Request.QueryString("status").ToString()
                If status = "NOTADMIN" Then
                    lblWarning.Text = "Sorry you are not allowed to access the site. Please contact Site Admin."
                End If
            Catch ex As Exception
                Dim a As String = ""
            End Try
        End If
    End Sub

    Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click


        If TbUsername.Text <> "" OrElse TbPassword.Text <> "" Then
            Session.Timeout = 480
            Dim accessData As New DataAccess()
            Dim User As String = TbUsername.Text
            Dim Username As String() = User.Replace("\", "|").Split("|"c)
            Session("Username") = Nothing
            Dim Authentication As Boolean = IsUserAuthenticated("LDAP://" & Username(0).ToString(), Username(0).ToString(), Username(1).ToString(), TbPassword.Text.Trim())
            If Authentication = True Then
                StaticObject.UserName = ""
                StaticObject.Password = ""
                StaticObject.Domain = ""

                StaticObject.Domain = Username(1).ToString()
                Session("UserName") = Username(1).ToString()

                StaticObject.Domain = Username(0).ToString()
                accessData.AddUser(Username(1).ToString())
                Dim Authorization As String = accessData.CheckUserAccess(Username(1).ToString())
                Dim MyAuthorization As String() = Authorization.Split("|"c)
                StaticObject.UserLevel = MyAuthorization(0).ToString()
                StaticObject.IsAdmin = MyAuthorization(1).ToString()
                If MyAuthorization(0).ToString() <> "9" Then
                    Session("displayName") = StaticObject.DisplayName
                    Response.Redirect("Home.aspx")

                Else
                    lblWarning.Text = "Sorry you are not allowed to access this Site, please contact the Site Administrator"

                End If
            Else
                lblWarning.Text = "User Name or Password incorrect! Note: 3 consecutives incorrect login your account will be locked!"
            End If
        End If

    End Sub
    Public Function IsUserAuthenticated(ByVal strAdPath As String, ByVal strDomain As String, ByVal strUserName As String, ByVal strPassword As String) As Boolean
        Dim directoryEntry As New DirectoryEntry(strAdPath, strUserName, strPassword)

        Dim directorySearcher As New DirectorySearcher(directoryEntry)
        Dim Authentication As [Boolean]

        Try

            Dim searchResult As SearchResult = directorySearcher.FindOne()
            Authentication = True
            ' authenticated 
            'string a = directoryEntry.Properties["displayName"].Value.ToString();
            directorySearcher.Filter = "(&(objectClass=person) (samaccountname=" & strUserName & "))"
            Dim result As SearchResult = directorySearcher.FindOne()
            Dim resultEntry As New DirectoryEntry()
            resultEntry = result.GetDirectoryEntry()

            'Properties.Item("displayName").Value.ToString())
            StaticObject.DisplayName = resultEntry.Properties("displayName").Value.ToString()
        Catch ex As Exception
            Authentication = False
            ' not authenticated 
            TbUsername.Text = ""
            TbPassword.Text = ""
        End Try
        Return Authentication

    End Function

   

End Class


CSS
so basically it is using windows login.

The poblem is that :
The page does not recognize that there is already a session. Therefore, still showin the login button when it should be logout because the user was able to login.

Here is the code:



VB
Private user As StaticObject = Nothing
   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       If Session("displayName") Is Nothing Then
           lblUserFullName.Text = "null"
       Else
           If Not Page.IsPostBack Then
               Try
                   lblUserFullName.Text = StaticObject.DisplayName
               Catch ex As Exception
               End Try
           End If
       End If
   End Sub
   Protected Sub loginstatus_LoggedOut(ByVal sender As Object, ByVal e As System.EventArgs) Handles loginstatus.LoggedOut
       Session.Abandon()
       Session.Clear()
   End Sub
   Protected Sub loginstatus_LoggingOut(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs) Handles loginstatus.LoggingOut
   End Sub


SQL
thank you very much in advance and I made sure I did my best to fix this before seeking for help.

AnswerRe: Login problem Pin
jkirkerx3-Jul-12 8:28
professionaljkirkerx3-Jul-12 8:28 
Generalxsl and xsl fo transformations Pin
indian1433-Jul-12 5:42
indian1433-Jul-12 5:42 
SuggestionRe: xsl transformations Pin
AspDotNetDev3-Jul-12 7:20
protectorAspDotNetDev3-Jul-12 7:20 
GeneralRe: xsl and xslfo transformations Pin
indian1433-Jul-12 8:01
indian1433-Jul-12 8:01 
QuestionCreating Dynamic control in oninit method Pin
ankushbelorkar3-Jul-12 5:15
ankushbelorkar3-Jul-12 5:15 
AnswerRe: Creating Dynamic control in oninit method Pin
R. Giskard Reventlov3-Jul-12 5:20
R. Giskard Reventlov3-Jul-12 5:20 
AnswerRe: Creating Dynamic control in oninit method Pin
jkirkerx3-Jul-12 7:46
professionaljkirkerx3-Jul-12 7:46 
QuestionMultiple ScriptManager.RegisterStartupScript Issue Pin
Vimalsoft(Pty) Ltd2-Jul-12 21:11
professionalVimalsoft(Pty) Ltd2-Jul-12 21:11 
AnswerRe: Multiple ScriptManager.RegisterStartupScript Issue Pin
Sandeep Mewara2-Jul-12 23:18
mveSandeep Mewara2-Jul-12 23:18 
GeneralRe: Multiple ScriptManager.RegisterStartupScript Issue Pin
Vimalsoft(Pty) Ltd2-Jul-12 23:19
professionalVimalsoft(Pty) Ltd2-Jul-12 23:19 
GeneralRe: Multiple ScriptManager.RegisterStartupScript Issue Pin
Sandeep Mewara2-Jul-12 23:34
mveSandeep Mewara2-Jul-12 23:34 
QuestionASP .Net Pin
Member 34876322-Jul-12 18:49
Member 34876322-Jul-12 18:49 
AnswerRe: ASP .Net Pin
Sandeep Mewara2-Jul-12 19:48
mveSandeep Mewara2-Jul-12 19:48 
GeneralRe: ASP .Net Pin
Member 34876323-Jul-12 20:06
Member 34876323-Jul-12 20:06 
AnswerRe: ASP .Net Pin
ZurdoDev3-Jul-12 4:02
professionalZurdoDev3-Jul-12 4:02 
GeneralRe: ASP .Net Pin
CodingLover3-Jul-12 4:07
CodingLover3-Jul-12 4:07 
GeneralRe: ASP .Net Pin
Member 34876323-Jul-12 20:10
Member 34876323-Jul-12 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.