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

推荐订阅源

博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
G
Google Developers Blog
B
Blog
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
The Cloudflare Blog
The Hacker News
The Hacker News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
雷峰网
雷峰网
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
量子位
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
H
Help Net Security
Help Net Security
Help Net Security
P
Palo Alto Networks Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
N
News | PayPal Newsroom
AWS News Blog
AWS News Blog
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
腾讯CDC
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
TaoSecurity Blog
TaoSecurity Blog
GbyAI
GbyAI
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
Docker

博客园 - Samgle

HttpRequest重写,解决资源占用/链接超时/分块下载事件通知 问题。 PDF-XChange 3.0 / Pro4.0注册码 Welcome to the Live Labs Pivot Technical Preview 修复 VS2008 asp.net 设计视图 失效/工具-选项[Html设计视图]出现"加载此属性页时出错" 方案 对于JavaScript的 Stack overflow at line 错误总结 - Samgle 10 Free Chart Scripts 如何让mvc运行在IIS6.0上? (ASP.NET MVC on IIS 6 Walkthrough) Live.com MSN 在线状态查询接口(JSON数据输出) - Samgle BIND9.5b1 for windows 2003 Google Maps by asp.net API集成-S.Sams Olympic Medal 如何在asp.net中用jQuery实现便捷的提示功能和表单验证功能-S.Sams jQuery jGrow 改进版 通过代理访问 http://sourceforge.net/ 常用简易JavaScript函数 世界真細小 (原曲: It's A Small World), 作曲: Richard She 做下笔记, Response 文件流类型 推荐微软官方Windows Server 2008实战攻略系列下载 Most used CSS tricks
解决删除域用户Exception from HRESULT: 0x80072030
Samgle · 2013-11-27 · via 博客园 - Samgle

解决删除域用户异常问题。


System.DirectoryServices.DirectoryServicesCOMException was unhandled
  Message=在服务器上没有这样一个对象。 (Exception from HRESULT: 0x80072030)
  Source=System.DirectoryServices
  ErrorCode=-2147016656
  ExtendedError=8333
  ExtendedErrorMessage=0000208D: NameErr: DSID-031001CD, problem 2001 (NO_OBJECT), data 0, best match of:
    'CN=Users,DC=samshum,DC=com'

解决方案代码:

        private const string AdPath= "LDAP://192.168.8.151";
        private const string AdUser= "administrator";
        private const string AdPassWord= "1231112123";

        /// <summary>
        /// 删除指定用户
        /// </summary>
        /// <param name="sAMAccountName"></param>
        public void DeleteUserByAccount(string sAMAccountName)
        {
            GetCommonName(sAMAccountName);
        }

        /// <summary>
        /// 删除指定用户,通过用户全称
        /// </summary>
        /// <param name="NickName"></param>
        public void DeleteUserByNickName(string NickName)
        {
            using (DirectoryEntry entry = new DirectoryEntry(ADPath, ADUser, ADPassword))
            {
                using (DirectorySearcher Search = new DirectorySearcher())
                {
                    Search.SearchRoot = entry;
                    Search.Filter = "(&(objectClass=user) (cn=" + NickName + "))";
                    SearchResult Result = Search.FindOne();
                    using (DirectoryEntry child = Result.GetDirectoryEntry())
                    {
                        child.DeleteTree();
                        child.Close();
                        child.Dispose();
                    }
                    Search.Dispose();
                }
                entry.Close();
                entry.Dispose();
            }
        }