惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
博客园_首页
H
Help Net Security
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
B
Blog
I
InfoQ
SecWiki News
SecWiki News
T
Tailwind CSS Blog
Spread Privacy
Spread Privacy
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
P
Palo Alto Networks Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
M
MIT News - Artificial intelligence
S
Schneier on Security
T
Threat Research - Cisco Blogs
F
Fortinet All Blogs
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The Cloudflare Blog
Recent Announcements
Recent Announcements
Security Latest
Security Latest
G
GRAHAM CLULEY
IT之家
IT之家
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
腾讯CDC
Google DeepMind News
Google DeepMind News
V
V2EX
S
Securelist
TaoSecurity Blog
TaoSecurity Blog
B
Blog RSS Feed
S
SegmentFault 最新的问题
博客园 - 叶小钗
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Project Zero
Project Zero
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure

博客园 - 海盗

How to point your package manager to US server How to install Java in Ubuntu [Linux]Variable and Parameters in Bash - 海盗 HOWTO: Install chinese input One series article of Linux file system Reading notes of &lt;&gt; -- I <> - 海盗 - 博客园 Got two days' break New keyboard - 海盗 - 博客园 Some questions before learning ASP.net MVC framework Back again! JavaScript MD5 Encryption - 海盗 AJAX中的Back Button/Bookmarking问题和Nikhil Kothari的Atlas解决方案 My 50 favorite design resources IE ToolBar 关于C#中字段的初始化 关于namespace - 海盗 - 博客园 好久没来了! C#播放音乐
复杂域环境下通过.Net操作Active Directory经验点滴
海盗 · 2006-07-02 · via 博客园 - 海盗

1、操作ACL

操作ACL需要使用ActiveDs这个Com组件。

在上篇文章的回复中Rock提到“很多ActiveDs.dll提供的功能是.net的AD访问组件不提供的”。ACL的操作就是这样。

但是我在操作ACL的时候发现在2003上很正常的程序在2000下不能通过,报出“Security ID Structure is invalid”,中文是“安全 ID 结构无效”。

在KB上找到一篇文章:http://support.microsoft.com/default.aspx?scid=kb;en-us;316329

原来是操作系统在绑定SID的时候有问题。KB中提供了两个解决方法:

A) 人工操作ACL(晕倒,要是人工操作我还写代码干什么,B4)

B) 通过监视网络确认是否连接到的DC无法响应。因为我操作的实际环境是一个很复杂的域环境,这种情况不可避免。

没办法,我只好老老实实地把程序部署到2003的环境下了。

2、LDAP

大家都知道,一般我们用DirectoryEntry这个类来操作AD对象。

DirectoryEntry类的构造函数通过指定Path就可以绑定到DC。例如,我们常用的LDAP:LDAP://CN=onecity,OU=corp,DC=fabrikam,DC=com

一般来说,没有什么问题。但是有时候会报错说无法连接到域。

原因和上面所说的情况类似。这里我详细解释一下:

在添加域控制器的时候,DC会把本机所有的有效IP地址都注册到DNS中。在使用nslookup fabrikam.com时,会发现针对这个域(fabrikam.com),有很多对应的IP地址。但是DC服务器可能有多块网卡,有的网卡并没有使用(甚至没有插网线),这个没有使用的网卡会产生168.x.x.x的地址,并且此地址同样会被注册到DNS中。在绑定域控制器时,系统会从域对应的IP中挑选一个去绑定,当然这个无效的地址也会被挑中。

因此,在设定Path时,最好指定DC服务器,例如,

LDAP://MYDC01/CN=onecity,OU=corp,DC=fabrikam,DC=com

该方式还有一个好处是在分布式的域环境下(例如,北京/上海/广州),应用程序可以挑选最近的域控制器。

指定DC服务器还需要注意通过尝试多个DC服务器进行容错。例如:如果MYDC01连接失败,自动尝试下一台DC服务器(LDAP://MYDC02/CN=onecity,OU=corp,DC=fabrikam,DC=com)。这个通过程序做到并不困难,就不在这里多说了。

在简单的域环境下(1-2台DC)操作AD很简单,但是复杂域环境下会出现很多意想不到的问题,此经验供大家参考。

posted on 2006-07-02 10:29  海盗  阅读(447)  评论()    收藏  举报