Questions tagged [principalcontext]

PrincipalContext class is part of the Microsoft .NET System Directory Services Account Management API. It encapsulates a server or a domain against which operations are performed. It is also used disambiguate the generic deprecated tag [tag:context].

PrincipalContext class is part of the Microsoft .NET System Directory Services Account Management API. It encapsulates a server or a domain against which operations are performed.

References

See the main documentation of this Class in in the MSDN library.

137 questions
0
votes
1 answer

Principle context return null value in asp.net mvc

I am trying to connect with active directory using principle context. i have tried with below code. using (var context = new PrincipalContext(ContextType.Domain, ConfigurationManager.AppSettings["DomainName"].ToString())) …
0
votes
0 answers

UserPrincipal.GetAuthorizationGroups() throwing exception when Distinguished Name in UserPrincipal contains special characters (a comma in my case)

I have a situation where I need to find AD Group of a user recursively. e.g. UserA is part of Group3, Group3 is part of Group2, Group2 is part of Group1 So, UserA is part of Group3, Group2, Group1. Now, to find all the groups for a user I have used…
raunakchoraria
  • 358
  • 2
  • 15
0
votes
1 answer

Calling ValidateCredentials Results In False (With Known Correct Username/Password), Event 4625 Showing On Domain Server

I am making a very simple call to PrincipalContext.ValidateCredentials under the domain context that is resulting in a false-negative for an unknown reason. using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "DOMAINNAME")) …
0
votes
0 answers

Getting group members from AD groups cross-domain

I need to get all the User objects that are part of a certain group (let's call it "SourceGroup") from Active Directory in domain MYDOMAIN.CC. This includes resolving nested groups (recursively). I am working with UserPrincipal and PrincipalContext…
Manuel Hoffmann
  • 539
  • 1
  • 7
  • 23
0
votes
1 answer

Different Thread.Principal in web Api custom attribute

In a Web API, I've created a TokenAuthentication attribute to verifying token that has come from client and after that the user should sign in, then i use my UserServiceManager to sign in like this: ApplicationUser aUser = new…
0
votes
0 answers

I want to check whether user is disable in Active Directory

I want to check if user is disabled in Active Directory. I have written following code but it is not working. private DataTable IsUserExists(DataTable dt) { DataTable temp = new DataTable(); temp.Columns.Add("DisplayName",…
0
votes
1 answer

Find Users by Query inside a Active Directory Group

Given a particular group with a lot of members, I want to query within the group to find members that have a DisplayName match. The code below is a non-functional example of what I'd like to accomplish. Note that I don't want to load the whole…
Steve Kinyon
  • 805
  • 1
  • 7
  • 15
0
votes
0 answers

Getting error "Server not operational" when using UserPrincipal and PrincipalCotext classes

I've seen many answers for that problem but none seem to fit to my. I'm strugguling very much with AD Authentication. The situation looks like this. We cave three domain controllers. We want to connecto the right one so that we don't get this…
0
votes
0 answers

Get all users from Active Directory Domain/AU using Directory Services

The code I have correctly creates a list (results) with all users with a name containing James. How can I change the code so that results will contain all users in the domain/ou? // create your domain context and define the OU container to…
Dawson
  • 457
  • 2
  • 9
  • 21
0
votes
1 answer

How would i assign only DisplayName and Name from PrincipalSearcher to List?

I have the following sample code: namespace DirectorySearcher { class Program { static void Main(string[] args) { using (var context = new PrincipalContext(ContextType.Domain, "bobo.net")) { using (var…
Dwayne Dibbley
  • 355
  • 3
  • 20
0
votes
0 answers

Connect to LDAP using PrincipalContext in C#

I am trying to connect to an LDAP server in C# using PrincipalContext. I've validated the network parameters and authentication settings are all correct using Apache Directory Studio. This is the code I'm using: string sDomain =…
elisa
  • 23
  • 1
  • 2
  • 6
0
votes
1 answer

Can't create PrincipalContext in ActiveDirectory

I am using this code from a .NET Forms application to try and create a PrincipalContext object. var oPrincipalContext = new PrincipalContext( ContextType.Domain, "mydomain.workgroup", …
Heinrich
  • 1,711
  • 5
  • 28
  • 61
0
votes
1 answer

What is Impersonation and how does it work with PrincipalContext

I need to logon a user on my application verifying his credentials. I found the old LogonUser API and the new PrincipalContext object. I'd really like to use the PrincipalContext because it's easy and smart, but I know that usign LogonUser you can…
rPulvi
  • 946
  • 8
  • 33
0
votes
1 answer

Clarification required about PrincipalContext security permissions and PrincipalContext's ContextType.Machine

using (PrincipalContext Context = new PrincipalContext(ContextType.Domain, DomainURL, UserName, Password)) { UserPrincipal Account = new UserPrincipal(Context); Account.GivenName = strFirstName; Account.Surname = strLastName; …
0
votes
1 answer

Establish a connection to Active Directory using PrincipalContext under the security context of an external service

using (PrincipalContext Context = new PrincipalContext(ContextType.Domain, DomainURL, UserName, Password)) { UserPrincipal Account = new UserPrincipal(Context); Account.GivenName = strFirstName; Account.Surname =…