高手请进!up有分!!关于用ADSI访问AD的问题!

sinsou 2003-03-27 03:36:28
我想用adsi(不是用DirectoryServices)列出ad中所有的组,我用过滤器怎么不起作用啊
代码如下:
Dim ctr As ActiveDs.IADsContainer
Dim obj As Object
Try
ctr = GetObject(ldapStr) 'ldapStr="ldap://machine/dc=xx,dc=xxx,dc=xxx"
ctr.Filter = "group"
For Each obj In ctr
If (obj.Name.ToString().ToLower() = resName.ToLower()) Then
........
Return True
End If
Next

Catch e1 As Exception
ctr = Nothing
Return False
End Try

ctr = Nothing
Return False
...全文
28 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
sinsou 2003-03-28
  • 打赏
  • 举报
回复
我不想用DirectoryServices,因为我的程序是用adsi,我不想将程序弄的太乱,我想adsi完全能够实现的
sungoodnews 2003-03-28
  • 打赏
  • 举报
回复
如何访问 Active Directory
“Active Directory 服务接口”(ADSI) 访问分布式计算环境中来自不同网络提供商的目录服务的功能,以提供单组目录服务接口来管理网络资源。管理员和开发人员可以使用 ADSI 服务来枚举和管理目录服务中的资源,而不管是哪种网络环境包含该资源。可使用 Active Directory 执行常见管理任务,如在整个分布式计算环境中定位资源。
本示例阐释如何在 Active Directory 中定位资源。它是一个小型控制台应用程序,可以从命令提示处运行。该应用程序采用一个命令行参数。第一个参数必须是指向一个 Active Directory 项的有效路径。

尝试运行以下命令,用所需路径替代特定网络的有效 Active Directory 路径:

> ADRead.exe "LDAP://CN=Clarify Operations Team,OU=Distribution Lists,DC=redmond,DC=corp,DC=microsoft,DC=com"


从 Active Directory 读取至少包括:
创建一个新的 DirectoryEntry:

DirectoryEntry objDirEnt = new DirectoryEntry(path);


Dim objDirEnt As DirectoryEntry = New DirectoryEntry(path)
从 Active Directory 读取信息并将信息输出到屏幕:

string tab = " ";
foreach(string key in objDirEnt.Properties.PropertyNames) {
Console.WriteLine(tab + key + " = ");
foreach(Object objCollection in objDirEnt.Properties[key])
Console.WriteLine(tab + tab + objCollection);
}








sungoodnews 2003-03-28
  • 打赏
  • 举报
回复
using System;
using System.DirectoryServices;

public class ADRead {
public static void Main(String[] args) {
if(args.Length!=1) {
Console.WriteLine("用法:" + Environment.GetCommandLineArgs()[0] + " <ad_path>");
Console.WriteLine ();
Console.WriteLine ("按 Enter 键继续...");
Console.ReadLine();
return;
}

DirectoryEntry objDirEnt=new DirectoryEntry(args[0]);
Console.WriteLine("名称 = " + objDirEnt.Name);
Console.WriteLine("路径 = " + objDirEnt.Path);
Console.WriteLine("架构类别名称 = " + objDirEnt.SchemaClassName);
Console.WriteLine("");
Console.WriteLine("属性::");

foreach(String Key in objDirEnt.Properties.PropertyNames) {
Console.Write("\t{0} = ", Key);
Console.WriteLine("");
foreach(Object objValue in objDirEnt.Properties[Key]) {
Console.WriteLine("\t\t{0}", objValue);
}
}
}
}

火电 2003-03-28
  • 打赏
  • 举报
回复
up

]强烈关注
sinsou 2003-03-28
  • 打赏
  • 举报
回复
up
zwztu 2003-03-27
  • 打赏
  • 举报
回复
强烈关注
sinsou 2003-03-27
  • 打赏
  • 举报
回复
没人来,只有自己up了

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧