principalcontext

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

一世执手 提交于 2019-12-11 07:35:23
问题 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 reference not set to an instance of an object. at changep1.changep2.changeUserPassword(String _userID, String _oldPassword, String _newPassword) in C:\Users\Intern\source\repos\changep1\changep1\changep2.aspx.cs:line 52 Here is my c# code: public

Getting error while finding AD Groups of a user using PrincipalContext

Deadly 提交于 2019-12-11 05:30:01
问题 I have a situation where I need to find AD groups of a user recursively. For Example : I have such group hierarchy - Group1 |_ Group2 |_ Group3 |_ UserA According to the hierarchy, Groups of UserA are Group1, Group2, Group3 For finding it through the code I have used following method : Dim UserP1 As UserPrincipal = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, Remote_ID) allrecursiveUserGroups = UserP1.GetAuthorizationGroups() This method would give me all the groups

Query PrincipalSearcher for containing multiple strings

佐手、 提交于 2019-12-10 23:52:35
问题 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 = new GroupPrincipal(ctx); qbeGroup.DisplayName = "Administrators"; qbeGroup.DisplayName = "Users"; PrincipalSearcher srch = new PrincipalSearcher(qbeGroup); return srch.FindAll().Select(g => g.Name).ToArray(); This code doesn't even seem to filter

The LDAP Server is Unavailable using PrincipalContext and ADLDS

雨燕双飞 提交于 2019-12-05 13:35:33
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 is not set, it fails. I can successfully update a user as long as its not password I'm trying to update. I've been reading a lot of different articles relating to this but not finding a resolution. Posting to see if I can get some fresh perspective on this issue, thanks for any input. EXAMPLE ContextType ctxType = ContextType.ApplicationDirectory;

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

瘦欲@ 提交于 2019-12-04 18:44:28
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 PrincipalContext(ContextType.Domain); UserPrincipal qbeUser = new UserPrincipal(ctx); qbeUser.GivenName = "Ramesh*"; // qbeUser.Surname = "Ramesh*"; // qbeUser.DisplayName= "Ramesh*"; PrincipalSearcher srch = new PrincipalSearcher(qbeUser); // find all matches foreach(var found in srch.FindAll()) { // } The problem is that I am able to search by only one filter.

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

大兔子大兔子 提交于 2019-12-03 12:25:46
问题 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 this: public UserModel Login(string username, string password, string ipAddress) { // Verify valid parameters if (username == null || password == null) return null; try { using (var pContext = new PrincipalContext(ContextType.Machine)) { //

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

[亡魂溺海] 提交于 2019-12-03 02:54:07
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 this: public UserModel Login(string username, string password, string ipAddress) { // Verify valid parameters if (username == null || password == null) return null; try { using (var pContext = new PrincipalContext(ContextType.Machine)) { // Authenticate against local machine if (pContext.ValidateCredentials(username, password)) { // Authenticate user

UserPrincipal.FindByIdentity() always returns null

徘徊边缘 提交于 2019-12-01 06:08:15
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.Domain)) { UserPrincipal user = UserPrincipal.FindByIdentity(context, IdentityType.Name, email);

How to connect to Active Directory with Principal Context?

余生长醉 提交于 2019-11-30 17:49:36
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 where the Active Directory is I get: "CN=DCESTAGIO,CN=SERVERS,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=estagioit,DC=local" I've tried the following connecting in the following ways: 1: PrincipalContext thisPrincipalContext = new PrincipalContext(ContextType.Domain, "192.168.56.101", "DC=estagioit,DC=local"); 2: PrincipalContext

How to connect to Active Directory with Principal Context?

若如初见. 提交于 2019-11-30 16:43:05
问题 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 where the Active Directory is I get: "CN=DCESTAGIO,CN=SERVERS,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=estagioit,DC=local" I've tried the following connecting in the following ways: 1: PrincipalContext thisPrincipalContext = new