[This is preliminary documentation and subject to change.]
Provides an implementation of the IPrincipal interface with dynamic list of roles.
For a list of all members of this type, see ExtendedPrincipal Members.
System.Object
LaMarvin.Constable.Principal.ExtendedPrincipal
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
The following example illustrates how the class can be used to implement custom role resolution mechanisms:
[Visual Basic] ' This creates a new ExtendedPrincipal associated with the current ' user's windows identity. Dim principal As ExtendedPrincipal = New ExtendedPrincipal(WindowsIdentity.GetCurrent()) ' The principal has no explicit roles defined, so the following assert ' must be true: Debug.Assert(Not principal.IsInRole("User")) ' Let's add the principal to the User role and verify membership. principal.Roles.AddNew("User") Debug.Assert(principal.IsInRole("User")) ' Now replace the User role with a WindowsRole, which maps to the ' local users Windows group. principal.Roles.RemoveAt("User") principal.Roles.Add(New WindowsRole("User", "BUILTIN\Users")) ' The following statement actually checks membership in the ' local users Windows group. This possible because the ExtendedPrincipal ' is associated with a WindowsIdentity and the User role is an instance ' of the WindowsRole class. Debug.Assert(principal.IsInRole("User")) [C#] // This creates a new ExtendedPrincipal associated with the current // user's windows identity. ExtendedPrincipal principal = new ExtendedPrincipal(WindowsIdentity.GetCurrent()); // The principal has no explicit roles defined, so the following assert // must be true: Debug.Assert(!principal.IsInRole("User")); // Let's add the principal to the User role and verify membership. principal.Roles.AddNew("User"); Debug.Assert(principal.IsInRole("User")); // Now replace the User role with a WindowsRole, which maps to the // local users Windows group. principal.Roles.RemoveAt("User"); principal.Roles.Add(new WindowsRole("User", @"BUILTIN\Users")); // The following statement actually checks membership in the // local users Windows group. This possible because the ExtendedPrincipal // is associated with a WindowsIdentity and the User role is an instance // of the WindowsRole class. Debug.Assert(principal.IsInRole("User"));
Namespace: LaMarvin.Constable.Principal
Assembly: LaMarvin.Constable (in LaMarvin.Constable.dll)
ExtendedPrincipal Members | LaMarvin.Constable.Principal Namespace