Click here to Skip to main content
15,887,331 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..
VB
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:
HTML
<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:

HTML
<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
Updated 15-Oct-12 4:29am
v9
Comments
n.podbielski 15-Oct-12 6:52am    
And you did wrote your own SqlRoleManager?
musiw 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

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!
 
Share this answer
 
Comments
musiw 22-Oct-12 2:52am    
i already tried your link still no success... :( i dont know how to solve this..
mgoad99 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900