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
34
votes
3 answers

System.DirectoryServices.AccountManagement.PrincipalContext broken after Windows 10 update

I've been using this little function without any issue for the past few years to validate user credentials. The createPrincipalContext method returns a PrincipalContext with ContextType.Machine and the machine name. public static bool…
Nkosi
  • 235,767
  • 35
  • 427
  • 472
25
votes
1 answer

How to connect to Active Directory with Principal Context?

I've been at this for a while and I'm always getting: System.DirectoryServices.AccountManagement.PrincipalServerDownException Which I think means my connection setup(connection string) is wrong. When I write "dsquery server" on cmd on the computer…
Vítor Martins
  • 1,430
  • 4
  • 20
  • 41
11
votes
1 answer

How to use PrincipalContext in .NET Core 2.0

I have created a web application in .NET Core 2.0 where I would like to use a PrincipalContext from namespace System.DirectoryServices.AccountManagement. I want to validate user agains Active Directory like this: private static ClaimsIdentity…
Jenan
  • 3,408
  • 13
  • 62
  • 105
11
votes
1 answer

Error when using PrincipalContext.ValidateCredentials to authenticate against a Local Machine?

I have a WCF service which contains a Login method that validates a username and password against the local machine credentials, and after a seemingly random period of time it will stop working for some users. The actual login command looks like…
Rachel
  • 130,264
  • 66
  • 304
  • 490
10
votes
1 answer

UserPrincipal.FindByIdentity() always returns null

I am using LdapAuthentication to log a user into Active Directory. I want to find all the groups that the user belongs to. I am using the following code: string adPath = "LDAP://OU=HR Controlled Users,OU=All…
MSOACC
  • 3,074
  • 2
  • 29
  • 50
9
votes
1 answer

How to set connection time out when establishing context - PrincipalContext

using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, Domain, UserName, Password)) { UserPrincipal U = new UserPrincipal(ctx); U.GivenName = strFirstName; U.Surname =…
StackTrace
  • 9,190
  • 36
  • 114
  • 202
7
votes
2 answers

UserPrincipal.IsMemberOf is returning false

I am trying to validate the user is in the "TestGroup" group or not. The user is part of the "TestGroup" group, even i am getting the retval = false @line(retVal = user.IsMemberOf(groupPrincipal);), and in event viewer it is showing msg as "The user…
user190881
  • 169
  • 2
  • 11
7
votes
0 answers

Active Directory PrincipalContext.ValidateCredentials when change password on next login policy is active

I am using the classes in System.DirectoryServices.AccountManagement namespace to interact with Active Directory from my web application. To authenticate user credentials against Active Directory I use the following line of code. bool…
6
votes
6 answers

Memory Leak when using PrincipalSearcher.FindAll()

I too have a long running service using plugins and appdomains and am having a memory leak due to using directoryservices. Note that I am using system.directoryservices.accountmanagement but it is my understanding that it uses the same underlying…
Richard
  • 286
  • 3
  • 9
5
votes
1 answer

Slow AD-LDS connection with the PrincipalContext-class via LDAP in SSL

On my dev machine I had to install an AD-LDS. In principal it works fine, however is the first connect to the AD-LDS via the PrincipalContext-class extremely slow (30 seconds+). It seems to me that it first tries to connect to some non existing host…
HCL
  • 36,053
  • 27
  • 163
  • 213
5
votes
1 answer

PrincipalContext - I Can't connect to a local openldap server

I have installed an openldap for windows server and I use LDAPAdmin to connect to it by its default values : Server=ldap://localhost:389 Base:dc=maxcrc,dc=com UserName:cn=Manager,dc=maxcrc,dc=com Password:secret Now I want to use PrincipalContext…
Beatles1692
  • 5,214
  • 34
  • 65
4
votes
1 answer

Windows Service LdapException: The LDAP server is unavailable

I have a Windows Service that provides data through WCF to a Windows Forms application. The service takes care also of user authentication, validating user password using LDAP over the company Active Directory servers. The problem is that it works…
gipinani
  • 14,038
  • 12
  • 56
  • 85
4
votes
1 answer

The LDAP Server is Unavailable using PrincipalContext and ADLDS

We are making use of ADLDS for our user management and authentication. We can successfully query the instance without problems. However, trying to perform an operation such as SetPassword will fail or even trying to create a new user if a password…
Scott
  • 729
  • 1
  • 11
  • 30
4
votes
2 answers

Can a single PrincipalContext be reused for the lifetime of an application?

Can an application create a PrincipalContext once and then reused it for the lifetime of the application? That would avoid the performance hit of recreating PrincipalContext with the same details before each call to Active Directory. Can a…
James Newton-King
  • 48,174
  • 24
  • 109
  • 130
4
votes
0 answers

AccessDenied while using UserPrincipal SetPassword method

I am getting an AccessDenied exception while changing user's password using UserPrincipal class. I am logging to an Asp.Net application through Windows Authentication (domain user). If I try to change other user's password I am getting the access…
1
2 3
9 10