principalcontext

C# PrincipalContext The network path was not found

梦想与她 提交于 2021-01-27 18:35:12
问题 I am trying to use PrincipalContext to check if a local user group exists on a remote computer. I am having problems with PrincipalContext : PrincipalContext ctx = new PrincipalContext(ContextType.Machine, machine, null, ContextOptions.Negotiate) It works in such scenarios: local to local machine local to virtual machine domain machine to workgroup machine However it doesn't work in opposite direction: virtual machine to local host workgroup machine to domain machine I am getting these errors

UserPrincipal.FindByIdentity() always returns null

浪尽此生 提交于 2020-01-21 07:27:54
问题 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 Users,DC=myDomain,DC=local"; LdapAuthentication adAuth = new LdapAuthentication(adPath); try { if (true == adAuth.IsAuthenticated("myDomain", txtLoginEmail.Text, txtLoginPassword.Text)) { string email = txtLoginEmail.Text; using (PrincipalContext context = new PrincipalContext(ContextType

How to use PrincipalContext in .NET Core 2.0

て烟熏妆下的殇ゞ 提交于 2020-01-14 07:36:10
问题 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 ValidateUser(string userName, string password) { var domain = GetDomainByLogin(userName); using (var pc = new PrincipalContext(ContextType.Domain, domain, null, ContextOptions.Negotiate)) { if (!pc.ValidateCredentials(userName, password)) return null;

How to validate the credentials passed to a `PrincipalContext`

筅森魡賤 提交于 2020-01-06 02:33:27
问题 This is a follow up to my previous question. Question What is the correct way of validating the credentials passed to a PrincipalContext ? Background In my application I instantiate a PrincipalContext using PrincipalContext(ContextType, String, String, String). I have a number of integration tests that fail when the credentials are incorrect (or the supplied credentials are not for an admin) so I want to be able to catch this. If the credentials are invalid PrincipalContext.ConnectedServer

Testing a `PrincipalContext` using `ValidateCredentials(null, null)` behaves unexpectedly

那年仲夏 提交于 2019-12-24 08:46:46
问题 I need to validate the credentials that are used to connect to an AD server. If if pass invalid credentials to PrincipalContext(ContextType, String, String, String) , PrincipalContext.ConnectedServer throws a System.DirectoryServices.DirectoryServicesCOMException which is discovered on the first use of the PrincipalContext . I am trying to test the credentials with PrincipalContext.ValidateCredentials(null, null) but I am having issues. According to the .NET Core 2.0 docs The

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

冷暖自知 提交于 2019-12-22 08:27:06
问题 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 to add users to my ou=People The problem is I can't even connect to the server using PrincipalContext. I have searched the Net and found a lot of answers on how to connect to a ldap server but none of them are working for me.I keep getting a

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

送分小仙女□ 提交于 2019-12-17 17:54:22
问题 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 ValidateCredentials(string username, string password, string domain = null) { try { using (var principalContext = createPrincipalContext(username, domain)) { username = GetLoginInfo(username).Username; // validate the credentials if (principalContext

Problems with extending s.ds.am.UserPrincipal class

☆樱花仙子☆ 提交于 2019-12-13 01:36:01
问题 I have been trying to extend the s.ds.am.UserPrincipal class in VS 2010 VB app as I require access to AD User properties that are not by default a part of the UserPrincipal. This is a new concept to me and I have found some useful code on here as well but I have run into 2 problems with my extensions that I cannot seem to figure out. Problem 1: When I attempt to use my UserPrincipalEx to retrieve a user I receive the following error. ERROR: Principal objects of type MyApp.UserPrincipalEx can