简体   繁体   English

是否有一个C#库,其行为类似于Active Directory的权限和组?

[英]Is there a C# library that behaves like Active Directory's Permissions and Groups?

I like the way permissions and groups work in Active Directory, but I don't want to actually tie my application in with AD. 我喜欢权限和组在Active Directory中的工作方式,但我不想将我的应用程序与AD绑定。

Is there an existing library out there that contains the same sort of functionality that AD has? 是否存在包含与AD相同功能的现有库? In particular, the ability to create groups, assign users to groups, add permissions to groups, and view a user or group's applied permissions? 特别是,能够创建组,将用户分配到组,添加组的权限,以及查看用户或组的应用权限?

The ActiveDirectoryMembershipProvider class inherits MembershipProvider. ActiveDirectoryMembershipProvider类继承MembershipProvider。

That means that you don't have to tie your application to AD per se, but to the MembershipProvider model. 这意味着您不必将应用程序绑定到AD本身,而是绑定到MembershipProvider模型。 This model is used throughout .net and works well with built in controls and classes. 此模型在整个.net中使用,适用于内置控件和类。

Here is a sample 这是一个例子

//Any of these will work
ActiveDirectoryMembershipProvider provider = new ActiveDirectoryMembershipProvider();
//SqlMembershipProvider provider = new SqlMembershipProvider();
//MyCustomMemebershipProvider provider = new MyCustomMemebershipProvider();

MembershipProvider membershipProvider = provider;

if (membershipProvider.ValidateUser("username", "password"))
{
    MembershipUser user = membershipProvider.GetUser("username", true);
}
else
{
    //Do something
}

I am no expert on this model, but have had some experience sub classing MembershipProvider and implementing IPrincipal, IIdentity etc. Doing this is really flexible and maintains a consistent architecture 我不是这个模型的专家,但是已经有了一些经验,可以对MembershipProvider进行子类化,并实现IPrincipal,IIdentity等。这样做非常灵活,可以保持一致的架构

You can use Authorization Manager (AzMan) for this, its part of Windows Server. 您可以使用授权管理器(AzMan),它是Windows Server的一部分。 To integrate with it from .NET, Enterprize Library 5 has class library types for it you can use. 要从.NET集成它,Enterprize Library 5具有您可以使用的类库类型。

You can setup a free LDAP server, eg OpenLDAP , and use DirectoryServices to access it, and any number of tools to administrate the LDAP directory. 您可以设置一个免费的LDAP服务器,例如OpenLDAP ,并使用DirectoryServices来访问它,以及管理LDAP目录的任意数量的工具 Some configuration required! 需要一些配置!

The advantage to using a standard directory service is in the plethora of administration tools and the ability to support any number of applications. 使用标准目录服务的好处在于过多的管理工具和支持任意数量的应用程序的能力。 The disadvantages is in learning to administrate and query the directory. 缺点是学习管理和查询目录。 Is there any particular reason you don't want to use AD? 您是否有任何特殊原因不想使用AD? If you're working on Windows, I'd strongly recommend it over most objections. 如果您正在使用Windows,我强烈建议您使用大多数异议。

If AD is too heavy for you, you can use ADAM which is a light AD, that you can configure with ADSI Edit provided with the latter. 如果AD对您来说太重,您可以使用ADAM,它是一个轻型AD,您可以使用后者提供的ADSI Edit进行配置。 Here is a good doc provided, and c onfiguration question on SO. 这是一个很好的文档提供,以及关于SO的配置问题

Moreover you can browse ADAM with the same kind of .NET APIs ( System.DirectoryServices.AccountManagement for instance). 此外,您可以使用相同类型的.NET API(例如System.DirectoryServices.AccountManagement )浏览ADAM。

May be you can use Microsoft-s AzMan-Authorization Manager as a wrapper for Active directory. 可能是您可以使用Microsoft的AzMan-Authorization Manager作为Active Directory的包装器。

It contains an API to program against to ask for permissions 它包含一个API来编程以请求权限

and a gui (azman.msc) where you can define roles and map rights and store them in an xml-file. 和gui(azman.msc),您可以在其中定义角色和映射权限并将它们存储在xml文件中。

It can be configured against Active Directory. 它可以针对Active Directory进行配置。

Two things. 两件事情。

First : 第一:

If you want to interact with a Directory you have to program on the top of LDAP APIs. 如果要与目录进行交互,则必须在LDAP API之上进行编程。 As far as I undestand ADSI is working on the top of LDAP, but it does not seem to be so independant of Active Directory. 据我所知,ADSI正在开发顶级LDAP,但它似乎与Active Directory无关。 I know that Novell who initiate the mono project edit a more independant C# library on the top of LDAP . 我知道启动mono项目的 Novell 在LDAP之上编辑了一个更独立的C#库

Second : 第二:

Permissions, I mean Access Control List (ACLs) are a non standard feature. 权限,我的意思是访问控制列表(ACL)是一个非标准功能。 The way permissions are implemented in Active directory, is different from the way they are implemented in Sun e-Directory (special attributes). 在Active Directory中实现权限的方式与在Sun e-Directory中实现权限的方式(特殊属性)不同。 For example in OpenLDAP permissions are implented in a kind of access filter. 例如,在OpenLDAP中,权限是在一种访问过滤器中实现的。

I may (hope to) be wrong, but I never heard about a library that federate permission in Directories. 我可能(希望)是错的,但我从来没有听说过一个联合目录许可的图书馆。

One library that I have read about is Rhino Security . 我读过的一个图书馆是Rhino Security It seems to handle authentication as well as authorization for business operations, and is probably worth a look. 它似乎处理身份验证以及业务操作的授权,可能值得一看。 I have not actually implemented it though, so I do not know how well it works. 我实际上并没有实现它,所以我不知道它有多好用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM