using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Permissions;
+using System.Security.Claims;
+using Microsoft.Win32.SafeHandles;
namespace System.Security.Principal {
[Serializable]
[ComVisible (true)]
public class WindowsIdentity :
-#if NET_4_5
System.Security.Claims.ClaimsIdentity,
-#endif
IIdentity, IDeserializationCallback, ISerializable, IDisposable {
private IntPtr _token;
private string _type;
static private IntPtr invalidWindows = IntPtr.Zero;
+ [NonSerialized]
+ public new const string DefaultIssuer = "AD AUTHORITY";
+
[SecurityPermission (SecurityAction.Demand, ControlPrincipal=true)]
public WindowsIdentity (IntPtr userToken)
: this (userToken, null, WindowsAccountType.Normal, false)
_info = info;
}
+ internal WindowsIdentity (ClaimsIdentity claimsIdentity, IntPtr userToken)
+ : base (claimsIdentity)
+ {
+ if (userToken != IntPtr.Zero && userToken.ToInt64() > 0)
+ {
+ SetToken (userToken);
+ }
+ }
+
[ComVisible (false)]
public void Dispose ()
{
return new WindowsImpersonationContext (userToken);
}
- // properties
+ [SecuritySafeCritical]
+ public static void RunImpersonated (SafeAccessTokenHandle safeAccessTokenHandle, Action action)
+ {
+ throw new NotImplementedException ();
+ }
+ [SecuritySafeCritical]
+ public static T RunImpersonated<T> (SafeAccessTokenHandle safeAccessTokenHandle, Func<T> func)
+ {
+ throw new NotImplementedException ();
+ }
+
+ // properties
+ sealed override
public string AuthenticationType {
get { return _type; }
}
get { return (_account == WindowsAccountType.Anonymous); }
}
- public virtual bool IsAuthenticated
+ override
+ public bool IsAuthenticated
{
get { return _authenticated; }
}
get { return (_account == WindowsAccountType.System); }
}
- public virtual string Name
+ override
+ public string Name
{
get {
if (_name == null) {
info.AddValue ("m_isAuthenticated", _authenticated);
}
+ internal ClaimsIdentity CloneAsBase ()
+ {
+ return base.Clone();
+ }
+
+ internal IntPtr GetTokenInternal ()
+ {
+ return _token;
+ }
+
private void SetToken (IntPtr token)
{
if (Environment.IsUnix) {
}
}
+ public SafeAccessTokenHandle AccessToken {
+ get { throw new NotImplementedException (); }
+ }
+
// see mono/mono/metadata/security.c for implementation
// Many people use reflection to get a user's roles - so many