ASP.net角色和项目 [英] ASP.net roles and Projects

查看:224
本文介绍了ASP.net角色和项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修改 - 改写我原来的问题给予更多的信息

EDIT - Rewrote my original question to give a bit more information

背景信息结果
在我的工作,我的工作为我们的客户ASP.Net Web应用程序。在我们的实现,我们使用的技术像MembershipProviders和RoleProviders Forms身份验证。一切都很顺利,直到我遇到了与配置的角色有些困难,因为角色是不是系统范围内,但涉及到客户账户和项目。

Background info
At my work I'm working on a ASP.Net web application for our customers. In our implementation we use technologies like Forms authentication with MembershipProviders and RoleProviders. All went well until I ran into some difficulties with configuring the roles, because the roles aren't system-wide, but related to the customer accounts and projects.

我不能说出我们准确的设置/配方,因为我觉得我们公司将不会批准该...

I can't name our exact setup/formula, because I think our company wouldn't approve that...

什么是客户/项目?结果
本公司提供,每年为我们的客户管理信息(或其他时间间隔)的基础。结果
在我们的系统中的客户/合同包括:

What's a customer / project?
Our company provides management information for our customers on a yearly (or other interval) basis.
In our systems a customer/contract consists of:


  • 一个帐户:有关本公司的信息

  • 每个帐户,一个或多个产品:管理信息的包,我们将提供

  • 每个产品的一个或多个测量:经过一段时间,在此我们收集和报告数据

外联网站点设置结果
最后,我们希望所有客户能够与我们的在线系统来访问他们的管理信息。外网由两个网站:

Extranet site setup
Eventually we want all customers to be able to access their management information with our online system. The extranet consists of two sites:


  • 公司网站:提供的帐户信息的概述以及产品

  • 测量站点:选择测量,在那段时间
  • 详细信息后,
  • Company site: provides an overview of Account information and the Products
  • Measurement site: after selecting a Measurement, detailed information on that period of time

测量部位是外网的最有趣的部分。我们将创造新的概述,报告,管理和维护是对研究的重要资源,子模块。

The measurement site is the most interesting part of the extranet. We will create submodules for new overviews, reports, managing and maintaining resources that are important for the research.

我们的Visual Studio解决方案包含了一些项目。命名门户网站的基础上的一个Web应用程序。该站点和模块是应用程序中的虚拟目录(使得它更容易事物之间共享MasterPages)。

Our Visual Studio solution consists of a number of projects. One web application named Portal for the basis. The sites and modules are virtual directories within that application (makes it easier to share MasterPages among things).

什么样的​​角色?结果
以下用户(阅读:角色)将要使用的系统:

What kind of roles?
The following users (read: roles) will be using the system:


  • 管理员:发展用户:)(不与客户相关的,完全访问权限)

  • 员工:我们公司的雇员(不与客户相关的,完全访问权限)

  • 客户超级用户:高层管理人员(完全访问他们的帐户/测量)

  • 客户联系人:联系主要联系人(完全进入自己的测量参数(s))

  • 客户经理:部门经理(有限访问,测量的具体数据)

什么ASP.Net用户?结果
该系统将有很多ASP.Net的用户,让我们专注于客户的用户:

What about ASP.Net users?
The system will have many ASP.Net users, let's focus on the customer users:


  • 的用户不会账户之间共享

  • 超级用户X会自动访问所有的(新)的测量

  • 用户Y可能是测量1的主要联系人,但对测量2没有作用

  • 用户Y可能是测量1的主要联系人,但对测量2管理者角色

  • 的部门经理是很多个人用户(每测量),如果经理ž有一个登录测量1,我们想,如果他在测量2再次参与使用该登录。

URL结构结果
这些都是在我们的应用程序的URL的典型:

URL structure
These are typical urls in our application:

  • http://host/login - the login screen
  • http://host/project - the account/product overview screen (measurement selection)
  • http://host/project/1000 - measurement (id:1000) details
  • http://host/project/1000/planning - planning overview (for primary contact/superuser)
  • http://host/project/1000/reports - report downloads (manager department X can only access report X)

我们还将创建一个文档的URL,在那里你可以申请一个特定的文档通过它的GUID。该系统将必须检查用户是否具有权限的文件。该文件相关的测量,用户或特定角色具有对文件的具体权利。

We will also create a document url, where you can request a specific document by it's GUID. The system will have to check if the user has rights to the document. The document is related to a Measurement, the User or specific roles have specific rights to the document.

什么问题? (终于))结果
角色是不够的,以确定哪些用户被允许看到/访问/下载特定项目。这是不够的,说某导航项目是经理访问。当用户请求测量1000年,我们要检查用户不仅拥有经理的作用,但对于测量1000经理的角色。

What's the problem? (finally ;))
Roles aren't enough to determine what a user is allowed to see/access/download a specific item. It's not enough to say that a certain navigation item is accessible to Managers. When the user requests Measurement 1000, we have to check that the user not only has a Manager role, but a Manager role for Measurement 1000.

总结:


  1. 我们如何限制用户使用自己的账户/测量?结果
    (记住超级用户看到所有的测量,一些管理人员只有特定的测量)

  1. How can we limit users to their accounts/measurements?
    (remember superusers see all measurements, some managers only specific measurements)

我们如何在产品/测量级别应用的角色?
(用户X可以primarycontact测量1,但只是用于测量的经理2)

How can we apply roles at a product/measurement level? (user X could be primarycontact for measurement 1, but just a manager for measurement 2)

我们如何可以限制对报告的屏幕,只有他们的部门经理报告的访问?

How can we limit manager access to the reports screen and only to their department's reports?

所有asp.net类的法宝,或许还有一个自定义的roleprovider实现。

All with the magic of asp.net classes, perhaps with a custom roleprovider implementation.

类似的问题#1 /问题结果
<一href=\"http://stackoverflow.com/questions/1367483/asp-net-how-to-manage-users-with-different-types-of-roles\">http://stackoverflow.com/questions/1367483/asp-net-how-to-manage-users-with-different-types-of-roles

推荐答案

什么你从我看到的各个岗位追求,是一个自定义角色的机制或者说另一种方式,一个自定义的授权机制。验证仍然可以使用标准的SqlMembershipProvider。

What you are seeking from the various posts that I see, is a custom role mechanism or said another way, a custom Authorization mechanism. Authentication can still use the standard SqlMembershipProvider.

我不知道该标准的角色提供程序会为你提供你想要的授权什么需要你有项目的情况下。但是,您可能调查编写自定义RoleProvider,看看你是否可以创造一些自定义的方法,将做到这一点。尽管如此,回答问题的目的,我会假设你不能使用SqlRoleProvider。

I'm not sure that the standard role provider will provide you with what you want as authorization requires that you have the context of the Project. However, you might investigate writing a custom RoleProvider to see if you can create some custom methods that would do that. Still, for the purposes of answering the question, I'm going to assume you cannot use the SqlRoleProvider.

所以,这里的一些潜在的架构:

So, here's some potential schema:

Create Table Companies
(
    Id int not null Primary Key
    , ...
)
Create Table Projects
(
    Id int not null Primary Key
    , PrimaryContactUserId uniqueidentifier
    , ...
    , Constraint FK_Projects_aspnet_Users
        Foreign Key ( PrimaryContactUserId )
        References dbo.aspnet_Users ( UserId )
)
Create Table Roles
(
    Name nvarchar(100) not null Primary Key
    , ...
)

Create Table ProjectCompanyRoles
(
    CompanyId int not null
    , ProjectId int not null
    , RoleName nvarchar(100) not null
    , Constraint FK_...
)

正如我之前所说的,对于包括PrimaryContact在项目表中的原因是为了确保只有一条给定项目。如果你把它作为一个角色,你就必须包括一串铁环跳code,以确保项目不分配多个PrimaryContact。如果是这样的话,那么从项目表中取出PrimaryContactUserId并使其发挥作用。

As I said before, the reason for including PrimaryContact in the Projects table is to ensure that there is only one for a given project. If you include it as a role, you would have to include a bunch of hoop jumping code to ensure that a project is not assigned more than one PrimaryContact. If that were the case, then take out the PrimaryContactUserId from the Projects table and make it a role.

授权检查将需要对ProjectCompanyRoles查询。同样,除了项目的背景和公司让使用默认的角色提供有问题的。如果你想使用的角色以及验证的.NET机制,那么你就必须实现自己的自定义RoleProvider。

Authorization checks would entail queries against the ProjectCompanyRoles. Again, the addition of the contexts of Project and Company make using the default role providers problematic. If you wanted to use the .NET mechanism for roles as well as authentication, then you will have to implement your own custom RoleProvider.

这篇关于ASP.net角色和项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆