NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Default Principal and Identity Object Classes

This section defines default Principal and identity objects shipped with the NGWS runtime. Applications may define their own objects to deal with specific needs. These objects may be referenced across multiple threads within an AppDomain, and so must be thread safe.

GenericPrincipal Object

namespace System.Security.Principal

public class GenericPrincipal : IPrincipal
{
   // Constructors   
   public GenericPrincipal (IIdentity identity, String [] roles) {}  

      // IPrincipal Properties
   public IIdentity Identity  { get; }

   // IPrincipal Method
   public virtual bool IsInRole(String Role);
}

GenericIdentity Object

namespace System.Security.Principal

public class GenericIdentity : IIdentity
{
   // Constructors.
   public GenericIdentity (String name)   
   public GenericIdentity (String name, String type)

   // IIdentity Properties
   public String Name { get; }
   public String Type { get; }
   public bool IsAuthenticated {get;}
}

Notes:

WindowsPrincipal Object

namespace System.Security.Principal

public class WindowsPrincipal : IPrincipal
{
    // Public Constructor
    public WindowsPrincipal (WindowsIdentity ntIdentity) {}

    // IPrincipal Property
    public IIdentity Identity { get;}
    
    // IPrincipal Method
    public virtual bool IsInRole (String Role);

    // Populate the list of NT groups in which this entity is present
    private  void PopulateGroups();
 }

Notes:

WindowsIdentity Object

namespace System.Security.Principal

public class WindowsIdentity : IIdentity
{

    // IIdentity Properties
    public   String    Name       { get; }
    public   String    Type       { get; }
   bool IsAuthenticated {get;}

   // WindowsIdentity Properties
   public int Token { get;}
   public bool IsGuest {get;}
   public bool IsSystem {get;}
    
   // Public Constructors, Token must be a valid Windows Token
    public WindowsIdentity (int Token) {}
    public WindowsIdentity (int Token, String type) {}
    public WindowsIdentity (int Token, String type, WindowsAccountType  acctType) {}
    public WindowsIdentity (int Token, String type,  WindowsAccountType acctType, bool isAuthenticated) {}


    // Try to impersonate based on the Windows Token
    public virtual WindowsImpersonationContext  Impersonate();
    public virtual WindowsImpersonationContext  Impersonate(int Token);

   // Static method to get a WindowsIdentity for the current 
   // execution token
   public static WindowsIdentity GetCurrent();

}

Where:

Enum WindowsAccountType {
   Guest;
   Normal;
   System;
}

public class WindowsImpersonationContext
{

    // Revert from the impersonation associated with this object
    public void Undo();
}

Notes: