2016-03-14 29 views
0

因此,我有一個登錄頁面和三個用戶所有這三個用戶都有一個主要的ID - 名稱,電子郵件,用戶名,密碼和所有的數據已經爲此輸入。如何授予訪問登錄用戶在asp.net/vb

  • 病人 - 文件夾頁 - Information.aspx ordermed.aspx
  • 醫生 - 文件夾頁 - Patientinfo.aspx Patientsorders.aspx
  • 藥房 - 文件夾頁 -Pharmacyinfo.aspx prescriptionorders。 aspx

患者在鏈接表上輸入一系列藥物(患者ID和醫學ID)

順序獲得通過的醫生誰批准或不批准

和藥店可以從訂單表中看到批准的訂單發送。

我想要做的就是隻允許醫生/患者/藥房與

我已經設置會話變量提供了一個改變時批准的,上面寫着批准的標籤對應的信息訪問他們網頁用戶登錄:

Imports System.Data.SqlClient 
Imports System.Data 

Partial Class Pages_Login 
Inherits System.Web.UI.Page 


Protected Sub btnlogin_Click(sender As Object, e As EventArgs) Handles btnlogin.Click 

    Dim patientNo As String 
    Dim password As String 
    Dim bAuthethicated As Boolean 
    patientNo = txtuser.Text 
    password = txtpassword.Text 
    bAuthethicated = CheckUser(patientNo, password) 

    If bAuthethicated Then 
     lblresult.Text() = "Login details are correct" 

    Else 
     lblresult.Text() = "Incorrect Student Number and/or Password" 


    End If 

End Sub 




Public Function CheckUser(patientNo As String, password As String) As Integer 
    Dim cmdstring As String = "SELECT * FROM Patient Where [email protected] AND [email protected]" 
    Dim found = 0 
    Using conn As New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Laura\Final_proj\App_Data\surgerydb.mdf;Integrated Security=True;Connect Timeout=30") 

     Dim cmd = New SqlCommand(cmdstring, conn) 
     cmd.Parameters.Add("@PATIENTNO", SqlDbType.NChar).Value = patientNo 
     cmd.Parameters.Add("@PASSWORD", SqlDbType.NChar).Value = password 
     conn.Open() 



     Dim reader = cmd.ExecuteReader() 

     While reader.Read() 
      Session("PatientId") = CInt(reader.Item("PatientId")) 
      found = CInt(reader.Item("PatientId")) 
     End While 

     reader.Close() 
    End Using 
    Return (found) 
End Function 

End Class 

但是我想從看到其他網頁,我一登錄患者獲得對自己個人信息的訪問限制等。 有人可以請幫忙我一直試圖讓這個工作整個週末。 親切的問候

勞拉

但是我想從看到其他頁面限制別人,我一登錄患者來訪問自己的個人信息

+0

[在Asp.Net中限制某些頁面功能或用戶界面以驗證用戶]可能的副本(http://stackoverflow.com/questions/10186549/restricting-certain-page-functionality-or-user-interface-to - 認證用戶) – Paddy

+0

這不是我的問題,他們正在使用c# – laurajs

+0

C#/ VB.net,使用的底層機制是相同的。您使用角色來定義他們可以訪問的頁面,但是如何限制對他們自己的信息的訪問,很大程度上取決於數據的結構,對於這種格式可能過於寬泛。 – Paddy

回答

0

您應該使用一個sitemap.xml的文件並將其放置在您的網站的根目錄中。它看起來像這樣:

<?xml version="1.0" encoding="utf-8" ?> 
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > 
    <siteMapNode roles="*"> 
    <siteMapNode title="Home" url="~/default.aspx" roles="*" description=""/> 
    <siteMapNode title="Courses" url="" roles="*" description=""> 
     <siteMapNode title="Live Virtual Training" url="~/VirtualTraining.aspx" description=""/> 
     <siteMapNode title="Course Catalog" url="~/Catalog.aspx" description=""/> 
     <siteMapNode title="Recorded Courses" url="~/RecordedCourses.aspx" description=""/> 
    </siteMapNode> 
    <siteMapNode title="Get MSDN" url="~/msdn.aspx" roles="*" description="" /> 
    <siteMapNode title="RSS" url="~/RSS/Default.aspx" roles="*" description=""> 
     <siteMapNode title="MSDN Magazine" url="~/RSS/MsdnMagazineRss.aspx" description=""/> 
     <siteMapNode title="MSDN Virtual Labs" url="~/RSS/MsdnVirtualLabs.aspx" description=""/> 
     <siteMapNode title="C#" url="~/RSS/CsharpRss.aspx" description=""/> 
    </siteMapNode> 
    <siteMapNode title="Blog" url="~/wordpress/index.php" roles="*" description="" /> 
    <siteMapNode title="Trainers Wanted" url="~/Trainers.aspx" roles="*" description=""/> 
    <siteMapNode title="About Us" url="~/About.aspx" roles="*" description=""/> 
    <siteMapNode title="Contact Us" url="~/Contact.aspx" roles="*" description=""/> 
    <siteMapNode title="Student Resources" description="" roles="Administrators, Student"> 
     <siteMapNode title="Files" url="~/Files/Default.aspx" description="" roles="Administrators, Student" /> 
     <siteMapNode title="Recordings" url="~/Recordings/Default.aspx" description="" roles="Administrators, Student" /> 
    </siteMapNode> 
    <siteMapNode title="Administrative" description="" roles="Administrators"> 

    </siteMapNode> 
    </siteMapNode> 

</siteMap> 

請注意,某些路徑標有角色=屬性?這使您可以使用ASP.NET成員資格和角色數據庫,並只允許某些成員訪問您網站的某些區域。

+0

你可以使用角色管理器來做到這一點嗎?這是爲我的數據庫已創建的用戶 – laurajs

+0

我相信。但是,我自己並沒有這樣做。 –

+0

請注意,此*僅*用於控制渲染菜單中這些頁面的可見性。它不會阻止人們直接瀏覽這些網頁。 – Paddy

相關問題