Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET VB.NET
Hi all,
 
can someone help me on this problem.it's been a week.i dont know how to solve this..
my login page is reach to human resource table (oracle) then i compare (role) to my own table..
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        Dim con As New OracleConnection(OracleString)
        con.Open()
        Dim log As String
        log = "Select Distinct J.Emplid, P.Name, " +
        "C.Descr Dept From PS_JOB J, PS_JOB JD " +
        "Where J.Emplid = '" + Request("UID") + "' "
       
 
        Dim cm As New OracleCommand(log, con)
        cm.Connection = con
        'cm.CommandText = log
        'Dim name As String = DirectCast(cm.ExecuteScalar(1), String)
        'Label1.Text = DirectCast(cm.ExecuteScalar(1), String)
        'cm.ExecuteNonQuery()
        Dim d As OracleDataReader = cm.ExecuteReader()
        d.Read()
        Label1.Text = d.GetString(1)
        Label4.Text = d.GetString(3)
 
        Session("sEmplid") = d.GetString(0)
        'Dim cm As New OracleCommand()
        'cm.Connection = con
        'cm.CommandText = log
        'Dim id As String = DirectCast(cm.ExecuteScalar(0), String)
        'Label3.Text = DirectCast(cm.ExecuteScalar(0), String)
        Session("sNama") = Label1.Text
        Session("sDept") = Label4.Text
        'Session("sEmplid") = Label3.Text

       
        checkrole()
 

 
    End Sub
 
    Protected Sub checkrole()
        Dim role As String
        Dim con As New SqlConnection(connectionString)
        con.Open()
        If (Session("sEmplid") <> "") Then
            Dim r As String = "Select roles from logs where Emplid = '" + Session("sEmplid") + "'"
            Dim c As New SqlCommand(r, con)
            c.Connection = con
            Dim d As SqlDataReader = c.ExecuteReader()
            d.Read()
            If DBNull.Value.Equals(d("roles")) Then
                Label2.Text = "user"
                role = Label2.Text
                Session("sRole") = role
                Response.Redirect("home.aspx")
            Else
                Label2.Text = d.GetString(0)
                role = Label2.Text
                Session("sRole") = role
                Response.Redirect("home.aspx")
            End If
        Else
            Response.Redirect("login.aspx")
 
        End If
 

        If (Session("sRole") = "user" Or Session("sRole") = "manager" Or Session("sRole") = "general" Or Session("sRole") = "master") Then
        
        Response.Redirect("home.aspx")
        Else
        Response.Redirect("login.aspx")
        End If
 
       
    End Sub
web.config:
<sitemap enabled="true">
            <providers>
                <clear />
                <add sitemapfile="Web.sitemap" name="AspNetXmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" securitytrimmingenabled="true" />
            </providers>
        </sitemap>
 
        <authentication mode="Forms">
            <forms name ="pageForm" loginUrl="~\login.aspx" defaultUrl="~\home.aspx"></forms>
        </authentication>
 

 

    <location path="approval.aspx">
            <system.web>
                <authorization>
                    <allow users="master" />
                    <deny users="*" />
                </authorization>
            </system.web>
        </location>
web.sitemap:
 
<sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
    <sitemapnode roles="*">
        <sitemapnode url="home.aspx" title="Home" description="" />
        <sitemapnode url="status.aspx" title="Status" description="" />
        <sitemapnode title="Approval by GM ISM" description="GM ISM Use Only" url="approval.aspx" />
        <sitemapnode url="logout.aspx" title="Logout" description="" />
    </sitemapnode>
 

</sitemap>
 

 

the problem is; whenever i login (no matter what user id) the menu appear for role user. seems like role master doesnt work at all in web config..please help me..
 
thanks
musiw.
Posted 15-Oct-12 0:14am
musiw648
Edited 15-Oct-12 4:29am
v9
Comments
n.podbielski at 15-Oct-12 6:52am
   
And you did wrote your own SqlRoleManager?
musiw at 15-Oct-12 10:34am
   
in logs table, there is column for roles..master,manager,general.the rest is user. whenever i login (try multiple emplid with different roles)it is not working..i can tell by looking at the menu. i write xml file menu which approval.aspx only for master,general.the rest of the menu for all.currently my menu only appear for user role.menu master didnt appear

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

From briefly looking over what you have done, it looks like you forgot to authenticate the user using FormsAuthentication.SetAuthCookie after you set the session variables and roles.
 
Here is a link to a CP article on forms authentication with SQL Server, but you should be able to replace the SQL part with your Oracle code.
 
FormsAuthentication.SetAuthCookie(username, false);[^]
 
Best of luck!
  Permalink  
Comments
musiw at 22-Oct-12 2:52am
   
i already tried your link still no success... :( i dont know how to solve this..
mgoad99 at 22-Oct-12 17:09pm
   
I think n.podbelski's comment about the role manager is helpful. It seems like you may need to implement a custom membership provider. I'm sorry I can't help you more. But, that may be something to check into. Good luck.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 717
1 ChauhanAjay 135
2 Maciej Los 130
3 ashok rathod 90
4 ChintanShukla 90
0 Sergey Alexandrovich Kryukov 10,200
1 OriginalGriff 6,987
2 CPallini 5,850
3 George Jonsson 4,015
4 Gihan Liyanage 3,266


Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100