일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
- 일상
- AD
- C#
- 산출물
- 설계프로세스
- Windows 7
- T-SQL
- 글모음
- ERWIN
- 지리산둘레길
- union
- WinForm
- bitnami
- BCP
- Flume
- .net
- 소프트웨어공학
- MindMap
- hive
- Gundam
- ClickOnce
- MindManager
- 프로젝트관리
- SQL
- diskpart
- hadoop
- 프라모델
- Xcode
- garbage collection
- redmine
- Today
- Total
Blue sky, wind, cloud and knulf
AD에서 목록 조회 본문
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
// Login to AD
string strLdapPath = "LDAP://192.168.10.10/DC=kitg,DC=local";
DirectoryEntry objDE = new DirectoryEntry(strLdapPath, "xenadmin", "xenxptmxm");
try
{
DirectorySearcher searcher = new DirectorySearcher(objDE);
//searcher.Filter = "(&(objectCategory=person)(objectClass=user))";
searcher.Filter = "(objectCategory=organizationalUnit)";
SearchResultCollection srs = searcher.FindAll();
foreach (SearchResult sr in srs)
{
if (sr != null)
{
DirectoryEntry objUser = sr.GetDirectoryEntry();
Console.WriteLine("======================================================================");
//Console.WriteLine("distinguishedName: " + objUser.Properties["distinguishedName"].Value.ToString());
foreach (string key in objUser.Properties.PropertyNames)
{
Console.WriteLine(key + ": " + objUser.Properties[key].Value.ToString());
}
Console.WriteLine("\n");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}