我正在使用 Linq to SQL 编写 Sharepoint Provider 托管的应用程序,以根据数据库设计创建数据库。我需要为我的应用程序实现身份验证和授权。关于如何对用户进行身份验证/授权涉及一些逻辑:
当用户在 SharePoint 中单击应用程序时:
- 用户的电子邮件地址是从 SharePoint 上下文中读取的。
- 应用程序查看用户的电子邮件地址是否在
Accounts
表中(自定义数据库)。 - 应用程序确定,如果用户在表中找到
Accounts
,他在Accounts表中具有哪个角色。 View
根据用户渲染Role
- 如果在表中未找到用户
Accounts
,则显示错误消息而不是重定向到登录页面。
注意:当用户来自 SharePoint 时,他看不到登录页面
当用户直接调用登录页面 url 时:
- 显示登录页面
- 用户输入凭据(来自 SharePoint 的带有密码的电子邮件)
Accounts
应用程序通过检查表来检查这些凭据是否有效。- 如果凭据有效,还要检查
Accounts
表中的角色。 View
根据用户角色进行渲染。
这是Accounts
表格:
**Accounts**
------------
UserName (string, SharePoint E-Mail)
Password
Role (string, value from struct)
这是我的自定义Roles
结构:
public struct Roles
{
public struct UserRoles
{
public const string NormalUser= "NormalUser";
public const string PrivilegedUser = "PrivilegedUser ";
}
public struct AdminRoles
{
public const string SuperAdmin = "SuperAdmin ";
public const string ProjectsAdmin = "ProjectsAdmin ";
public const string UsersAdmin = "UsersAdmin ";
}
}
基本上,这就是我必须处理的。我有点困惑,因为有很多可能性。我真的不想将角色保留在自定义数据库中,所以我不想使用RoleProvider
.