directoryentry

Can I speed up this query to retrieve all computers on the domain?

邮差的信 提交于 2019-12-24 02:14:06
问题 I wrote a helper class to get all computers on a domain, but it's a tad bit slow. While there are 128 objects returned, I'd still like to speed it up. Any ideas? public class DomainBrowser { private const string Computer = "computer"; public string Domain { get; private set; } public DomainBrowser(string domain) { this.Domain = domain.ToLower(); } /// <summary> /// This method returns a list of the computer names available in the current domain. /// </summary> /// <returns></returns> public

which port(s) are used by DirectoryEntry?

北战南征 提交于 2019-12-24 02:06:24
问题 My goal is to get the list of web site names from remote server. But I'm getting the exception: The RPC server is unavailable. Here is the code: public List<string> GetWebSites(string serverIP) { List<string> names = new List<string>(); DirectoryEntry Services = new DirectoryEntry(string.Format("IIS://{0}/W3SVC", serverIP)); Services.Username = "user name"; Services.Password = "password"; IEnumerator ie = Services.Children.GetEnumerator(); DirectoryEntry Server = null; while (ie.MoveNext()) {

Force local user to change password at next login with C#

我是研究僧i 提交于 2019-12-23 09:58:54
问题 I'm writing a function for a web app in ASP.NET where the client logs into the server machine, which is Windows authenticated against the local users on the server. The function I am writing resets the users password and emails them the new one. I do this like so: String userPath = "WinNT://" + Environment.MachineName + "/" + username.Text; DirectoryEntry de = new DirectoryEntry(userPath); de.Invoke("SetPassword", new object[] { password }); How can I also check the flag to force the user to

When does WinNT:// provider query Active Directory? Or how to get SID of local group member if it is domain account

落爺英雄遲暮 提交于 2019-12-23 04:52:34
问题 Okay so I am using the WinNT provider with a DirectoryEntry class to enumerate the members of a local group, through the Members property. If the member is a local account, the DirectoryEntry will also be read from the SAM on the local machine presumably. If the member is a Domain Account however, will the provider perform a query to Active Directory when I access the properties of the DirectoryEntry object? Is there a way to differentiate the two scenarios? For example check a property on

How to get a list of all domains?

爷,独闯天下 提交于 2019-12-18 13:32:26
问题 I'm trying to get all domains that are available in the Windows Login dialog (in the Domain dropdown). I've tried the following code but it only returns the domain I am logged into. Am I missing something? StringCollection domainList = new StringCollection(); try { DirectoryEntry en = new DirectoryEntry(); // Search for objectCategory type "Domain" DirectorySearcher srch = new DirectorySearcher(en, "objectCategory=Domain"); SearchResultCollection coll = srch.FindAll(); // Enumerate over each

System.IO.FileNotFoundException: The network path was not found. Exception while using DirectoryEntry object on windows 7

谁都会走 提交于 2019-12-12 15:56:05
问题 i am trying to connect to remote windows 7 machine by using DirectoryEntry object. here is my code DirectoryEntry obDirEntry = new DirectoryEntry("WinNT://hostName", "hostName\\testUser", "password123", AuthenticationTypes.Secure); try { if (obDirEntry.Properties.Count > 0) { //ok } } catch (Exception excp) {} if i am able to connect to remote windows server 2003 machine or local windows 7 machine , then i didn't get any error. But when i am trying to connect to remote windows 7 machine then

Cannot set password with DirectoryEntry.Invoke when user is created in AD using ASP.NET C#

这一生的挚爱 提交于 2019-12-11 03:55:21
问题 A Web Application is creating a user from a Personnel Management Page which in turn adds the user to the Active Directory. Here is code to do this: DirectoryEntry Folder = new DirectoryEntry("LDAP://XXXX.com/CN=ContainerName, DC=XXXX, DC=com", admin, adminPwd, AuthenticationTypes.None); if (Folder.SchemaEntry.Name == "container") { DirectoryEntry user = Folder.Children.Add("CN=" + txtFirstname.Text + " " + txtLastname.Text, "User"); if (DirectoryEntry.Exists(user.Path)) { // Error Msg Here }

How can I check if a user has write rights in Active Directory using C#?

不羁的心 提交于 2019-12-11 01:39:29
问题 In my .NET 2.0 C# applcation I need to determine if a user (with password) has ability to modify (write) option in Active Directory. I hope there is a way using DirectoryEntry without creating and then deleting new object in AD. Thank you for your help. 回答1: Like Olive said, it's difficult to do it right yourself. It's difficult to do right because the permissions can be passed onto your user account via Active Directory groups. So, in order to find out the effective permission for a

Set Windows/AD password so that it “never expires”?

牧云@^-^@ 提交于 2019-12-10 16:12:00
问题 Here is my code: using (DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer")) { DirectoryEntry NewUser = AD.Children.Add(username, "user"); string password = username + "123"; NewUser.Invoke("SetPassword", new object[] { password }); NewUser.CommitChanges(); NewUser.Close(); DirectoryEntry grp; grp = AD.Children.Find(groupname, "group"); if (grp != null) { grp.Invoke("Add", new object[] { NewUser.Path.ToString() }); } } And what i want to do is to create

Impersonation and DirectoryEntry

安稳与你 提交于 2019-12-10 04:05:00
问题 I am impersonating a user account successfully, but I am not able to use the impersonated account to bind to AD and pull down a DirectoryEntry . The below code outputs: Before impersonation I am: DOMAIN\user After impersonation I am: DOMAIN\admin Error: C:\Users\user\ADSI_Impersonation\bin\Debug\ADSI_Impersonation.exe samaccountname: My issue seems similar to: How to use the System.DirectoryServices namespace in ASP.NET I am obtaining a primary token. I understand that I need to use