ASP.NET - Get the Principal / Relative Identifier (RID) for a DirectoryEntry / 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. When the ActiveDirectoryMembershipProvider is used, the ProviderUserKey object for the MembershipUser is as follows SecurityIdentifier sid = (SecurityIdentifier)Membership.GetUser().ProviderUserKey; string sidValue = sid.ToString(); /* sidValue = "S-1-5-21-XXXX-XXXX-XXXX-YY" */ As I understand it, YY is the principal within the namespace (also referred to as a group/domain). When using the custom