Questions tagged [userprincipal]

Encapsulates and exposes some principals or constructors of the active directory userprincipal class.

Encapsulates and exposes some principals or constructors of the active directory userprincipal class.

Link: UserPrincipal Methods

170 questions
16
votes
1 answer

HttpClient set credentials for Kerberos authentication

I am trying to authenticate with a kerberos/HTTP host. Using Apache HttpClient as my client - and a slightly modified version of this source. My Kerberos authentication goes perfectly fine, and I wish to know how to set the login credentials…
Alavalathi
  • 713
  • 2
  • 9
  • 21
14
votes
2 answers

Determine if user is in AD group for .NET 4.0 application

I am trying to determine if a user is a member of an Active Directory (AD) group for an internal ASP.NET 4.0 application. The code below throws an "Attempted to access an unloaded appdomain" exception error on the last line (return statement) in…
Dave Johnson
  • 782
  • 1
  • 7
  • 17
12
votes
5 answers

Get nETBIOSName from a UserPrincipal object

I am using the System.DirectoryServices.AccountManagement part of the .Net library to interface into ActiveDirectory. Having called GetMembers() on a GroupPrincipal object and filter the results, I now have a collection of UserPrincipal…
Grhm
  • 6,726
  • 4
  • 40
  • 64
12
votes
2 answers

How I get Active Directory User Properties with System.DirectoryServices.AccountManagement Namespace?

I want do get Active Directory Properties from a user and I want to use System.DirectoryServices.AccountManagement. my code: public static void GetUserProperties(string dc,string user) { PrincipalContext ctx = new…
Tarasov
  • 3,625
  • 19
  • 68
  • 128
11
votes
2 answers

How to get number of connected users and their role using j_security_check?

I get the username of the connected user (using j_security_check) this way, through a managed bean: ...... username = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal().getName(); And then display it in a jsf page this…
Hanynowsky
  • 2,970
  • 5
  • 32
  • 43
9
votes
1 answer

Spring Security: setUserPrincipal manually

In a webapplication with Spring MVC and Spring Security. Is there a way to set UserPrincipal manually? I need to switch to another user by an admin part of my webapplication. In my controller, is it possible to setUserPrincipal in the request? To…
BasicCoder
  • 1,661
  • 10
  • 27
  • 42
9
votes
1 answer

Unable to find User after specifying a container for PrincipalContext

I'm attempting to find a User by username in Active Directory. This works: const string Domain = "SLO1.Foo.Bar.biz"; const string Username = "sanderso"; PrincipalContext principalContext = new PrincipalContext(ContextType.Domain,…
Sean Anderson
  • 27,963
  • 30
  • 126
  • 237
9
votes
4 answers

How can I get a list Local Windows Users (Only the Users that appear in the windows Logon Screen)

How can I get a list of Local Windows Users (Only the Users that appear in the windows Logon Screen) I have tried many methods using Windows Principle library & WMI Select commands. I keep getting Administrator, Guest & some other bizarre accounts…
Neil Hobson
  • 515
  • 1
  • 7
  • 14
9
votes
3 answers

System.DirectoryServices.AccountManagement.UserPrincipal - localhost but not iis

Why does the code below work fine when I run my web application localhost but not when I install it to an IIS server? using (HostingEnvironment.Impersonate()) { UserPrincipal activeUser = UserPrincipal.Current; String activeUserSid =…
RichardD
  • 315
  • 1
  • 4
  • 11
9
votes
2 answers

Get the list of Groups for the given UserPrincipal

I want to get the list of groups which the user is in. This is my code: PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "mydomain.ac.uk", "DC=mydomain,DC=AC,DC=UK", "user", "password"); UserPrincipal user =…
TTCG
  • 8,805
  • 31
  • 93
  • 141
8
votes
1 answer

Extending UserPrincipal; FindByIdentity() fails

Extending UserPrincipal to take advantage of its built-in properties... running into an issue when we overload the FindByIdentity() method. From Microsoft's example at http://msdn.microsoft.com/en-us/library/bb384372%28VS.90%29.aspx (parts…
7
votes
2 answers

UserPrincipal.GetAuthorizationGroups() is slow

For some reason GetAuthorizationGroups() seems to be taking around 20 seconds to return the groups. I am using this code: UserPrincipal user; // This takes 20 seconds user.GetAuthorizationGroups().OfType().ToList(); Anyone got any…
Cheetah
  • 13,785
  • 31
  • 106
  • 190
6
votes
2 answers

Extend UserPrincipal class

I do the extension of the UserPrincipal class to retrieve some missing properties that i need: [DirectoryObjectClass("user")] [DirectoryRdnPrefix("CN")] class UserPrincipalExt : UserPrincipal { public UserPrincipalExt(PrincipalContext context) …
6
votes
1 answer

How to search for users in Global Catalog within AD forest with multiple trees

I have the following AD forest with two trees: Domain1. Has two child domains Domain2 and Domain3 Domain4. Doesn't have child domains. DNS name of the Domain1 is domain1.local. DNS name of the Domain4 is domain4.local. In each domain there is a…
Aides
  • 467
  • 2
  • 5
  • 16
6
votes
2 answers

Getting UserPrincipal with Windows authentication and anonymous authentication on

The following code only works while only Windows Authentication is enabled in IIS for local users on our network. using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain)) { UserPrincipal up = UserPrincipal.FindByIdentity(ctx,…
mservidio
  • 12,817
  • 9
  • 58
  • 84
1
2 3
11 12