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
1
vote
3 answers

using linq on active directories underlying object

Currently my code is: using (var context = new PrincipalContext(ContextType.Domain, adDomain)) { using (var searcher = new PrincipalSearcher(new UserPrincipal(context))) { foreach (Principal result in searcher.FindAll()) { …
Bryan Dellinger
  • 4,724
  • 7
  • 33
  • 79
1
vote
1 answer

Skip Active Directory Authentication in a Visual Studio project

I know almost nothing about Active Directory so pardon me if this question seems silly. I have been hired as a remote developer for a project. The application on which I suppose to work relies on Active Directory authentication. As I am not part of…
Manvinder
  • 4,495
  • 16
  • 53
  • 100
1
vote
1 answer

Principal Extension for UserPrincipal in .NET throwing an "Unwilling to process request" error

I am trying to set the value of an extension attribute in AD with my VB.NET executable. I extended the UserPrincipal class to accomplish this but now I get an error The server is unwilling to process the request when I try to set the extended…
1
vote
1 answer

C# PrincipalContext only changes password for some users, not all

I'm trying to change the AD password of all members in my system, but my code only changes the password for some members successfully. For members whose password can't be changed, it shows the following error: System.NullReferenceException: Object…
1
vote
1 answer

PrincipalContext.ValidateCredentials with cached credentials in C#

I'm trying to authenticate users in an application using a domain controller with code like this: PrincipalContext pcon = new PrincipalContext(ContextType.Domain, domain); password_ok = pcon.ValidateCredentials(username, password); That works fine…
jcgalveza
  • 371
  • 5
  • 13
1
vote
1 answer

PrincipalContext: Exception Details: System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred

I am trying to search AD for a user, but it keeps throwing an exception. The application is setup to use AppPool. and I am certain that the logged in user has access to search AD. Code: public static UserADInfoModel ResolveUserProperties(string…
1
vote
1 answer

Why am I getting "No security object matching the specified parameters found" error (GroupPrincipal)

I'm creating a program that adds and removes domain users to/from local groups on a specific computer. I successfully finished part that adds users to group, but when it comes to removing I'm getting this error. Exception thrown:…
Tae
  • 11
  • 6
1
vote
1 answer

PrincipalContext.ValidateCredentials: find username or password is invalid

I am using AD authentication in my application: bool _isValid; using (var pc = new PrincipalContext(ContextType.Domain, DomainPath)) { isValid = pc.ValidateCredentials(username, password, ContextOptions.Negotiate); } Is there any way to…
Penman
  • 163
  • 3
  • 14
1
vote
0 answers

View group members of local security C# skipping unresolved sid

While enumerating members of local group of server remotely, I am getting error because of unresolved sids. Is there any work around skip such group members. PrincipalContext dt = new PrincipalContext(ContextType.Machine, server1); string…
1
vote
0 answers

UserPrincipal.FindByIdentity Unable to cast object of type 'GroupPrincipal' to type 'UserPrincipal

Good morning, i'm trying to find a user in our active directory, but am getting the following exception: {System.SystemException} = {"Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type …
1
vote
1 answer

Need help in converting DirectoryServices code to PrincipalContext

DirectorySearcher deSearch;SearchResultCollection result; deSearch.SearchRoot = baseResult.GetDirectoryEntry();// I know this one can be done like - PrincipalContext pContext = new PrincipalContext(ContextType.Domain,…
nimish jain
  • 141
  • 1
  • 13
1
vote
0 answers

PrincipalContext throwing object reference not set to instance

var path = abcdev.xyz.com:636; PrincipalContext context = new PrincipalContext(ContextType.Domain, path) Error:Object reference not set to an instance of an object. at…
Scorpio
  • 1,151
  • 1
  • 19
  • 37
1
vote
1 answer

How to validate non administrator user using c#?

I have created a local user. (Ex: mymachine\user1). I do not want to add this user to administrator group. I have used following c# code to validate my local account: PrincipalContext contextmachine = new PrincipalContext(ContextType.Machine); …
1
vote
1 answer

How to use encrypted password in source code for Directory Services authentication

I wrote a program that reads the UserPrincipal of an User in our Active Directory via PrincipalContext. For this the authentication of a privileged user is needed. At the moment the password for this authentication is saved as plaintext in the…
1
vote
1 answer

What to store in database to identify Active Directory and local account users

I am writing a permissions system for my WPF application that needs to work with both Active Directory and local machine accounts; the system may or may not be connected to a network. The user can log into the application with either an AD login…
wta
  • 78
  • 7