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

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

博客园 - bestcomy

在OPENSUE 11.3 上安装 sysstat Upload bug in MOSS 2007 / Windows Server 2008 - bestcomy Excel列名转换 Clienside ProgressIndicator - bestcomy - 博客园 ASP.NET MVC 源代码发布! 微软项目组招聘.NET开发人员(北京) 欢迎访问我的新BLOG空间 SharePoint 胡言乱语 你觉得vs.net那些地方让你使用起来很不爽? Include javascript and css dynamically - bestcomy Two ways to get HtmlTextWriter for HTML rendering How to set value for webpart’s properties when I create a new sharepoint template Get the true value of a calculate field in SharePoint 调用自定义event时需要注意的一个问题 self==top 微软 and 香烟 Cool!!! Virtual Earth Technology Preview sth about our coding life 还没有Windows Live Messenger的朋友看过来
如何设置AD用户的"用户下次登陆时须更改密码"属性 (LDAP Provider)
bestcomy · 2006-07-04 · via 博客园 - bestcomy

最近要给客户做培训需要配置一个测试环境,因为系统使用域用户验证,建立大量的域用户工作量比较大,而且测试环境的用户名可以根据用户单位和角色建立一个用户名模式,例如:角色.单位

于是用c#批量建立用户,发现这样两个比较棘手的问题:
1. 如何设置用户名初始密码
2. 如何设置“用户下次登陆时须更改密码”不选中(缺省选中)

最终的测试建立用户的代码如下:

 1 DirectoryEntry AD = new DirectoryEntry("LDAP://dc=cnblogs,dc=com","administrator","pa$$word",AuthenticationTypes.Secure);
 2             DirectorySearcher searcher = new DirectorySearcher(AD);
 3             searcher.Filter = String.Format("ou={0}","Blogs");
 4             SearchResult result = searcher.FindOne();
 5             if(result!=null)
 6             {
 7                 string samAccountName = "tester";
 8                 string displayName = "测试创建";
 9                 DirectoryEntry userEntry = result.GetDirectoryEntry().Children.Add(String.Format("CN={0}",samAccountName),"User");
10                 userEntry.Properties["sAMAccountName"].Add(samAccountName);
11                 userEntry.Properties["displayName"].Add(displayName);
12                 userEntry.Properties["UserPassword"].Add("pa$$word");
13                 userEntry.Properties["userAccountControl"].Value = 544;
14                 userEntry.Properties["pwdLastSet"].Value = -1;
15                 userEntry.CommitChanges();
16                 userEntry.Invoke("SetPassword",new object[] {"pa$$word"});
17             }

顺便做一个小小的招聘广告,哈哈,大家见谅。
朋友最近要我推荐几个程序员,北京地区的.net程序员均可将简历通过以下地址给我
bestcomy at hotmail.com   ( at 替换为@)
请在简历上写好联系方式,如果合适会主动有人联系你。