directoryservices

“The specified domain either does not exist or could not be contacted.”

做~自己de王妃 提交于 2019-12-11 14:14:55
问题 I'm trying to use the DomainServices class to retrieve a list of OU's from my Active Directory. Here's my code: public List<OrganizationalUnit> FindOrganizationalUnits(string domainName, string domainExtension, string parentOrganizationUnit) { string tmpDirectory = String.Format("LDAP://ou={0},dc={1},dc={2}", parentOrganizationUnit, domainName, domainExtension ); DirectoryEntry directory = new DirectoryEntry(tmpDirectory); DirectorySearcher searcher = new DirectorySearcher(directory);

Active Directory move a user to a different OU

≡放荡痞女 提交于 2019-12-11 12:53:10
问题 I'm working on a program that will automate the separation process for users leaving our network. One of the tasks it performs is moving the user account from the OU it is in, to a Former Employees OU. I've been having problems with this step even though I've not had any issues doing other processes with DirectoryServices . Here's my code thus far (note: I know I need to stop catching and eating all exceptions. This will be addressed and corrected before release. Any advice on which

Does SearchResultCollection's GetDirectoryEntry have to query ActiveDirectory again? [DirectoryServices/.net]

末鹿安然 提交于 2019-12-11 12:32:45
问题 When using the FindAll() method of the DirectorySearcher in .net, does the GetDirectoryEntry() method of the SearchResultCollection require another trip to Active Directory? e.g.... Dim src As SearchResultCollection Dim ds As New DirectorySearcher ' code to setup DirectorySearcher ' go to Active Directory and fill collection with results src = ds.FindAll() '...later on in code or whatever ' does the next line of code require another trip to Active Directory? Dim de As DirectoryEntry = src

How to list domains running code from a non-domain computer?

柔情痞子 提交于 2019-12-11 06:41:42
问题 In my application I need to get Active Directory forest and list the domains hierarchy. I was given the Active Directory account that has necessary permissions. However my development computer is NOT on the domain and can not be added to the domain. Here is the code that I am using to get the forest and access the root domain: // I also tried to add a Global Catalog port: 192.168.2.11:3268, no success DirectoryContext dc = new DirectoryContext( DirectoryContextType.Forest, "192.168.2.11",

How does one connect to the RootDSE and/or retrieve highestCommittedUSN with System.DirectoryServices.Protocols?

你离开我真会死。 提交于 2019-12-11 06:16:18
问题 Using System.DirectoryServices, one can get the highestCommittedUSN this way: using(DirectoryEntry entry = new DirectoryEntry("LDAP://servername:636/RootDSE")) { var usn = entry.Properties["highestCommittedUSN"].Value; } However, I need to get this information from a remote ADLDS using System.DirectoryServices.Protocols, which does not leverage ADSI. Following is a simplified code sample of what I'm attempting to do: using(LdapConnection connection = GetWin32LdapConnection()) { var filter = "

How to change passwords using System.DirectoryServices.Protocols

落爺英雄遲暮 提交于 2019-12-11 05:34:31
问题 Our user store is an LDAP server called eDirectory. How do you change user passwords using System.DirectoryServices.Protocols? 回答1: I've used code similar to this to connect to a Sun One-based LDAP to change a user's password. (Shouldn't be that different from Novell eDirectory...) using System.DirectoryServices.Protocols; using System.Net; //... // Connect to the directory: LdapDirectoryIdentifier ldi = new LdapDirectoryIdentifier("theServerOrDirectoryName"); // You might need to specify a

Why is PrincipalContext.ValidateCredentials validating against old credentials?

假如想象 提交于 2019-12-11 05:16:29
问题 We have a WCF service that validates the user's credentials against the local windows accounts on the machine, however whenever a new user is created or a password is changed, users cannot login until I restart the entire machine. What can I do to tell it to check the credentials against the current user settings, and to not use old ones? using (var pContext = new PrincipalContext(ContextType.Machine)) { if (pContext.ValidateCredentials(username, password)) { using (var context = new

what does UserPrincipal.RefreshExpiredPassword() update?

耗尽温柔 提交于 2019-12-11 04:04:19
问题 as noted in this question, it resets the users password age to zero, but how? pwLastSet attribute still displays the old date. Is there another attribute? Is it better to just reset pwLastSet value to current date? 回答1: I know this question is old, but the source code is available now, so you can see exactly what it does. In short, it calls ADStoreCtx.UnexpircePassword() , which sets pwdLastSet to -1. At least that's what it does now. Who knows if it's been changed since 2014. Here's the

Dispose not working as expected in DirectorySearcher

六月ゝ 毕业季﹏ 提交于 2019-12-11 03:43:39
问题 I am trying to connect and do simple functionalities such as search on an Active Directory using C#. However, I am stuck in a problem. I am using DirectorySearcher to search the directory. There are loads of entries in the directory. This is the function void RunThis() { DirectoryEntry de = new DirectoryEntry(); de.Path = "LDAP://" + domainName; de.Username = username; de.Password = password; de.AuthenticationType = AuthenticationTypes.Secure; DirectorySearcher deSearch = new

Automatic log in to Active Directory

我们两清 提交于 2019-12-11 02:27:40
问题 I am having some difficulty with doing an automated login for users in my desktop Active Directory application. I may be trying to do an SSO, but I am under the impression that is only for web applications. The code I have, is this: PrincipalContext theContext = new PrincipalContext(ContextType.Domain); if (theContext.ValidateCredentials(null, null)) Console.WriteLine("Credentials have been validated. Tell your friends."); else Console.WriteLine("Invalid credentials"); UserPrincipal user =