DirectoryEntry用活动目录
DirectoryEntry groupAdmin = new DirectoryEntry("WinNT://" + Environment.MachineName + "/Administrators")去里面获取吧具体方法。
DirectoryEntry groupAdmin = new DirectoryEntry("WinNT://" + Environment.MachineName + "/Administrators")去里面获取吧具体方法。
try
{
DirectoryEntry entry = new DirectoryEntry("LDAP://CN=My Distribution List,OU=Distribution Lists,DC=Fabrikam,DC=com");
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.Filter = "(objectClass=*)"; uint rangeStep = 1000;
uint rangeLow = 0;
uint rangeHigh = rangeLow + (rangeStep - 1);
bool lastQuery = false;
bool quitLoop = false; do
{
string attributeWithRange;
if(!lastQuery)
{
attributeWithRange = String.Format("member;range={0}-{1}", rangeLow, rangeHigh);
}
else
{
attributeWithRange = String.Format("member;range={0}-*", rangeLow);
}
searcher.PropertiesToLoad.Clear();
searcher.PropertiesToLoad.Add(attributeWithRange);
SearchResult results = searcher.FindOne();
foreach(string res in results.Properties.PropertyNames)
{
System.Diagnostics.Debug.WriteLine(res.ToString());
}
if(results.Properties.Contains(attributeWithRange))
{
foreach(object obj in results.Properties[attributeWithRange])
{
Console.WriteLine(obj.GetType());
if(obj.GetType().Equals(typeof(System.String)))
{
}
else if (obj.GetType().Equals(typeof(System.Int32)))
{
}
Console.WriteLine(obj.ToString());
}
if(lastQuery)
{
quitLoop = true;
}
}
else
{
lastQuery = true;
}
if(!lastQuery)
{
rangeLow = rangeHigh + 1;
rangeHigh = rangeLow + (rangeStep - 1);
}
}
while(!quitLoop);
}
catch(Exception ex)
{
// Handle exception ex.
}
MSDN中的帮助代码
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.chs/ws_sds_conc/html/07560e99-624d-477c-8e4f-ed247756ebfd.htm
多谢glbinno 和zxkid两位前辈的指点。
找不到类型或命名空间名称“DirectoryEntry”(是否缺少 using 指令或程序集引用?)
还要定义哪个using System.?