ASP.NET - 获取主/相对标识符(RID)的一个DirectoryEntry / SID标识符、NET、ASP、SID

2023-09-09 21:37:33 作者:一袭水袖舞倾城

我正在使用自定义的MembershipProvider类的Active Directory在ASP.NET 2.0 Intranet应用程序验证用户身份和他们的SID与应用程序的配置文件相关联。

I am using Active Directory in a custom MembershipProvider class to authenticate users in an ASP.NET 2.0 intranet application and associate their sid with a profile for the application.

ActiveDirectoryMembershipProvider 时,为 ProviderUserKey 对象的MembershipUser 如下:

SecurityIdentifier sid = (SecurityIdentifier)Membership.GetUser().ProviderUserKey;
string sidValue = sid.ToString();

/* sidValue = "S-1-5-21-XXXX-XXXX-XXXX-YY"  */

据我了解, YY 是命名空间(也被称为一组/域)内的主体。

As I understand it, YY is the principal within the namespace (also referred to as a group/domain).

在使用自定义的MembershipProvider,我可以用一个DirectoryEntry对象的的objectSID 属性来获取SID

When using the custom MembershipProvider, I can get the sid using the objectSid property of a DirectoryEntry object

DirectoryEntry entry = new DirectoryEntry(path, username, password);
SecurityIdentifier sid = new SecurityIdentifier((byte[])entry.Properties["objectSid"].Value, 0);
string sidValue = sid.ToString();

/* sidValue = "S-1-5-21-XXXX-XXXX-XXXX"  */

sidValue 在这种情况下是相同的,只是它不包含本金 YY

The sidValue in this case is identical, except it does not contain the principal YY.

我的问题是双重的。

是为了唯一标识一个人所需要的本金? 是否有可能获得来自DirectoryEntry对象的委托人(或通过提供任何其他类的System.DirectoryServices )?

编辑:

已经做了一些进一步阅读( {1} 的