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
2 answers

C# - Not able to validate local machine user when ".\" is pre-append with username

I’m using System.DirectoryServices.AccountManagement library to validate a local user. I’ve got the following code: private bool IsValidWindowsUser(string userName, string password) { using (var p = new…
1
vote
2 answers

Search Users in Active Directory based on First Name, Last Name and Display Name

I trying to search my organization Active directory for users. If the FirstName or LastName or DisplayName matches a particular string value, it should return the users. My Code: // create your domain context PrincipalContext ctx = new…
1
vote
1 answer

C# Active Directory Principalcontext Permissions

I've been searching for an answer and can't seem to find one, but maybe I missed it. I have a WPF application and I use PrincipalContext to connect to MS AD. My development machine is not domain joined and I can connect no problem. However, on our…
0
votes
1 answer

How to overwrite ClaimIdentity from HttpRequestData.Identities while working with isolated azure function

I'm working with .net 7 isolated azure function. before processing the business I need to add more information to the Claim Identity like the code below: public async Task PreprocessingRequestAsync(**HttpRequestData request**,…
0
votes
0 answers

Microsoft graph, users memberships as readable strings?

I am new to Microsoft Graph, I am lost on getting the roles or memberships of the user I have found https://graph.microsoft.com/v1.0/me/memberOf?$select=* But this pretty much only returns and ID as a GUID, but no usable strings or any informatiuon…
sonnich
  • 151
  • 2
  • 11
0
votes
0 answers

Finding local users profile path in C# and creation of folder

I am creating a local user successfully with the following code, however the users folder is not created: using var context = new PrincipalContext(ContextType.Machine); using var user = new UserPrincipal(context); user.Name =…
morleyc
  • 2,169
  • 10
  • 48
  • 108
0
votes
1 answer

How is PrincipalContext.ValidateCredentials call registered or marked on DC?

I am using PrincipalContext.ValidateCredentials method from System.DirectoryServices.AccountManagement namespace to validate user credentials against Active Directory LDAP server. Sample of code: private bool…
0
votes
1 answer

Creating a PrincipalSearcher takes very long

Creating an instance of a PrincipalSearcher for accessing a local ActiveDirectory takes about 11 - 22 seconds. Interestingly the time is always 11 or 22 seconds, +/- a few milliseconds. The OU I'm trying to read out consists of not more than 30…
0
votes
1 answer

Howto create PrincipalContext to Synology LDAP Server

I get stuck with following problem: I want to use Synologys LDAP Service. Works fine. My config is: FDQN: "ldap.local" Base DN: "dc=ldap,dc=local" Bind DN: "uid=root,cn=users,dc=ldap,dc=local" allow anonymous (only for test !) don't force SSL Now…
Lama
  • 159
  • 1
  • 7
0
votes
1 answer

List of Active Directory users created on a specific date

Public Class Filters Inherits AdvancedFilters Public Sub New(ByVal p As Principal) MyBase.New(p) End Sub Public Sub CreatedAfter(ByVal value As Date) Dim strValue = value.ToString("yyyyMMddHHmmss.0Z") …
Lider13
  • 47
  • 7
0
votes
0 answers

specify an administrator username and password to search for users in Active Directory

Good day! This is how I search Active Directory Public Sub UserList(domain As String) Try Using context = New PrincipalContext(ContextType.Domain, domain) Dim userPrin As New UserPrincipal(context)…
Lider13
  • 47
  • 7
0
votes
1 answer

Add user to Active Directory Exception while calling Save function on UserPrincipal

I'm making a small forms application for adding a new user to Active Directory. After creating the PrincipalContext, I'm making the UserPrincipal and setting the properties of it. When I call Save on the UserPrincipal, the following exception is…
0
votes
1 answer

Is there a way to get users full path in active directory in ASP.Net Core?

I need to validate a specific user's path in active diretory in order to let him to autenticate to my website. Is there a method that I can user to get the full path. I've lood into PrincipalSearch but I don't think that works for a specific user,…
Sam
  • 247
  • 5
  • 16
0
votes
0 answers

.NET PricipalContext.ValidateCredentials always returns FALSE

I have Domain authentication implemented in the ASP.NET project. Using 4.5 .Net frameworks, 3.0.1 Microsoft.Owin dependencies. Here is how I am validating the user trying to login: using (var context = new PrincipalContext(ContextType.Domain,…
0
votes
0 answers

C# AD group count not correct

I am writing my first code to read all the members of an AD group and am not getting the correct number of group members: public static void GetListOfAdUsersByGroup (string domainName, string groupName) { PrincipalContext ctx = new…
John
  • 185
  • 1
  • 3
  • 17