-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathFindADUsers.cs
More file actions
28 lines (25 loc) · 779 Bytes
/
FindADUsers.cs
File metadata and controls
28 lines (25 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
using System.DirectoryServices.ActiveDirectory;
using System.Linq;
namespace SharpDomainSpray
{
public class ADUser
{
public List<string> ADuser()
{
DirectoryEntry directoryEntry = new DirectoryEntry("WinNT://" + Domain.GetComputerDomain());
List<string> userNames = new List<string>();
foreach (DirectoryEntry child in directoryEntry.Children)
{
if (child.SchemaClassName == "User")
{
userNames.Add(child.Name);
}
}
return userNames;
}
}
}