Questions tagged [iprincipal]

The System.Security.Principal.IPrincipal interface defines the basic functionality of a security object. It is most commonly used by applications written for the Microsoft.NET framework.

The System.Security.Principal.IPrincipal interface defines the basic functionality of a security object. This object represents the security context of the user on whose behalf the code is running, including that user's identity (IIdentity) and any roles to which they belong.

129 questions
2
votes
0 answers

Is there anyway to set IPrincipal in signalr application

We have used saml protection in Web application. I will pass claims as part of header to signalr. I want to read name claim and set IPrincipal in Signalr. I have tried by implementing Asp.net module and Set the context like below (sender as…
Balu
  • 23
  • 6
2
votes
0 answers

CustomPrincipal.IsInRole in ASP.NET MVC5

I am working in ASP.NET MVC 5 and I am using ASP.NET Identity. I have followed LukeP's solution here to get access to my ApplicationUser custom properties (e.g. User.DisplayUsername or User.DOB). Like Luke has suggested, I now have a custom…
J86
  • 14,345
  • 47
  • 130
  • 228
2
votes
3 answers

Unit Testing, how to set Thread.CurrentPrincipal and IsAuthenticated

I am trying to perform a unit test of an n-tier application, service layer, repository layer and web api controllers. My repositories are checking the Thread.CurrentPrincipal object to get the current user. This is where I have a problem, when I…
user1790300
  • 2,143
  • 10
  • 54
  • 123
2
votes
1 answer

OWIN Middleware's CurrentPrincipal.Identities have different claims set

Today I was configuring authorization provider for Oauth middleware and trying to insert some guid value into Thread.CurrentPrincipal.Identity.Claims. But when I tried to call Thread.CurrentPrincipal's FindFirst I've got nothing. Here is the example…
2
votes
1 answer

Update: Passing HttpContext and IPrincipal to Controler in ReSharper unit test

I'm attempting to run a couple basic unit tests on an ASP MVC controller, however at one point the controller needs to examine the IPrincipal User object like so: ViewBag.Level = Security.GetLevel(User); Once the unit test enters the Create…
NealR
  • 10,189
  • 61
  • 159
  • 299
2
votes
1 answer

Using PrincipalContext & PrincipalSearcher to access Active Directory users from separate server

I have the following code to retrieve the current active directory users: public List GetADUsers(string term=null) { List results = new List(); string ADServerName =…
John John
  • 1
  • 72
  • 238
  • 501
2
votes
1 answer

WebAPI - why setting Principal is needed in a Stateless mode?

I'm confused why in WebAPI it's needed to set the Principal, since each call is totally stateless. What's the benefit and the reason for set it up with your logged user info since each call is expected to be totally Stateless? I was under the…
SF Developer
  • 5,244
  • 14
  • 60
  • 106
2
votes
1 answer

Retrieving a user principal object using down-level user name

I'm having problems retrieving the User Principal object from AD as follows: public static UserPrincipal GetUserPrincipalByUserName(string userName, IdentityType identityType, string adUsername, string adPassword, string adDomain) { …
user2722002
  • 65
  • 1
  • 6
2
votes
1 answer

What does the Authorize attribute do by default in WebAPI?

I'm guessing that by default the [Authorize] attribute checks for a non null object that implements IPrincipal? Am I on the right track?
Alex KeySmith
  • 16,657
  • 11
  • 74
  • 152
2
votes
2 answers

How to set custom principal in asp.net

I am new to web application. I have created a custom principle and trying to set it in CurrentDomain. This code works perfectly in WPF application. But here it is throwing Policy Exception "Default principal object cannot be set twice." var…
D J
  • 6,908
  • 13
  • 43
  • 75
2
votes
1 answer

Store extra user session object with FormsAuthenticationTicket - cookie size too large

I am trying to setup a .NET MVC 3 project to store a custom user session object (which can then be later accessed from a Custom Principal object on other subsequent actions) I have followed the steps here: ASP.NET MVC - Set custom IIdentity or…
Marty
  • 2,965
  • 4
  • 30
  • 45
2
votes
2 answers

Are User in WebApiController and HttpContext.Current.User different?

After referring this post, I wrote an attribute for Basic Http Authentication to be used in the web api. In the attribute class, if the credentials provided match, then I am setting the HttpContext.Current.User as HttpContext.Current.User = new…
2
votes
1 answer

Selective IPrincipal Injection via StructureMap with SignalR

StructureMap is configured to inject HttpContext.Current.User when an IPrincipal is requested for any ASP.NET MVC web request, like so: For().Use(x => HttpContext.Current.User); But when my SignalR hub asks for a service that depends on…
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
1
vote
1 answer

WCF CustomRoleProvider and Principle Permissions

EDIT: I think that the issue may be related to the issue below as I'm also using SSL PrincipalPermission.Demand() failing once WCF Service was moved to SSL I'm working on a secure set of web services, I've implemented a CustomRoleProvider and…
1
vote
2 answers

Custom IAuthenticationFilter in ASP.NET Core 6 Web API based on Active Directory

I need to implement custom authorization based on some information in on-premise Active Directory. After doing some research, I figured that best approach would be to write a custom Authentication Filter and add that information from AD to the list…
1 2 3
8 9