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

UserPrincipal.IsMemberOf(GroupPrincipal) across domains ASP.Net

I am looking to amend a site to validate across domain but it gives the error below when run and login as the user from the other domain. Can you advise what security setting needs to be applied to the ASP.Net application pool to enable this? The…
2
votes
1 answer

Using PrincipalContext to search LDAP (Active Directory) for all usernames, and their information

I'm having problems with this code... apparently, it works, but is too slow for me, does anyone have any ideas? It slows down when I try to get access the following Dim u As UserPrincipal = UserPrincipal.FindByIdentity(ctx, p.SamAccountName) Again,…
TonyW
  • 766
  • 8
  • 17
2
votes
1 answer

UserPrincipal.FindByIdentity - throwing error on dev

I am working with an ASP.Net (using VB.Net) application. Testing and working locally this code block executes perfectly fine. Try Dim dc As PrincipalContext = New PrincipalContext(ContextType.Domain, "sanuk") Dim adUser As…
Simon Price
  • 3,011
  • 3
  • 34
  • 98
2
votes
0 answers

Error 6522 on PrincipalContext called from SQL CLR routine

I'm trying to add my first CLR routine to SQLServer 2008 (will upgrade to 2014 soon). The goal is to add a user object to Active Directory, passing in a dozen or so attribute values, to create the user based on data coming from an interface to an…
2
votes
0 answers

correct syntax of System.Security.Principal.NTAccount for Transfering to SecurityIdentifier

I want to create a System.Security.Principal.NTAccount object in order to transfer it for a System.Security.Principal.SecurityIdentifier , so I can use it to add a new access rule to Active Directory in .Net C# if I use this format : …
David Gidony
  • 1,243
  • 3
  • 16
  • 31
2
votes
0 answers

How to authenticate user using Directory Services AccountManagement with password hash

PrincipalContext ctx = new PrincipalContext(ContextType.Domain, Domain, UserName, Password) If i pass a correct password in code snippet above, authentication works fine but suppose i do not have the password but i have been provided with the …
2
votes
1 answer

C#.NET, Adding AD user to AD group - The object already exists

I've been tasked with creating a solution to add and remove AD users to and from AD groups. The following code is functional, except when I try to save the group. I'm getting an exception of "The object already exists." I've narrowed down the issue…
2
votes
2 answers

How to extend C# DirectoryServices UserContext with msTSProfilePath, msTSHomeDirectory etc

I need to read/write ActiveDirectory User object Terminal Services properties. I tried this: PrincipalContext context = new PrincipalContext(ContextType.Domain, "CA"); using (context) { UserPrincipal user =…
Vojin
  • 33
  • 4
2
votes
1 answer

Query PrincipalSearcher for containing multiple strings

I want to be able to query the active directory give a list of all groups containing certain words like Users or Administrators below is what i've got so far PrincipalContext ctx = new PrincipalContext(ContextType.Domain); GroupPrincipal qbeGroup =…
Sam Stephenson
  • 5,200
  • 5
  • 27
  • 44
2
votes
1 answer

PrincipalServerDownException on Windows XP but not on Windows 7

We have a WPF application that runs in full trust. Part of the application checks the membership of a Windows AD group. This works fine on a Windows 7 machine, but not on a Windows XP machine. The error occurs on the following line: PrincipalContext…
Shiraz Bhaiji
  • 64,065
  • 34
  • 143
  • 252
1
vote
0 answers

Principal context credential validations timing out

We are using the PrincipalContext.ValidateCredentials method to validate the user credentials. We observed recently that this method is taking more time and due to this application is timed out. During our initial analysis we found that if we pass…
1
vote
1 answer

Find user how to method work cross domain c#

The UserPrincipal.FindByIdentity(…) method does not work cross domain. the users outside of the domain the SingleSignOn app pool is running as are not being signed in automatically. When trying to access the SingleSignOn page as one of those users,…
1
vote
0 answers

LDAP connection without providing username and password in .NET Core

I have a project using .NET Core. I have a problem with authenticating LDAP connection. In .net framework, it's possible to authenticate LDAP connection without username and password but it's seems unable to work in .NET Core. Now how do you…
1
vote
1 answer

Validate user credentials and read associated groups for a user

Currently, I am validating the credentials of an Active Directory user with the help of this code: string _groups = ""; bool _isAuthSuccess=true; List user_groups = new List(); try { …
Sebastian
  • 4,625
  • 17
  • 76
  • 145
1
vote
1 answer

Get Primary Group From UserPrincipal C#

I want to locate the Primary Group from the code below I can get all the Groups for a user, but which one is the primary group? string primaryGroupName = String.Empty; using (PrincipalContext context = new…
nlstack01
  • 789
  • 2
  • 7
  • 30
1 2
3
9 10