Ejemplo n.º 1
0
 internal static unsafe bool CheckAuthenticated(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO *requestInfo)
 {
     if (requestInfo != null &&
         requestInfo->InfoType == UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeAuth &&
         requestInfo->pInfo->AuthStatus == UnsafeNclNativeMethods.HttpApi.HTTP_AUTH_STATUS.HttpAuthStatusSuccess)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 2
0
 internal static unsafe ClaimsPrincipal GetUser(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO *requestInfo, int infoCount)
 {
     for (int i = 0; i < infoCount; i++)
     {
         var info = &requestInfo[i];
         if (requestInfo != null &&
             info->InfoType == UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeAuth &&
             info->pInfo->AuthStatus == UnsafeNclNativeMethods.HttpApi.HTTP_AUTH_STATUS.HttpAuthStatusSuccess)
         {
             return(new WindowsPrincipal(new WindowsIdentity(info->pInfo->AccessToken,
                                                             GetAuthTypeFromRequest(info->pInfo->AuthType).ToString())));
         }
     }
     return(new ClaimsPrincipal(new ClaimsIdentity())); // Anonymous / !IsAuthenticated
 }