批量修改ad帐户属性



批量修改ad帐户属性

首页 系统管理脚本 管理 活动目录域管理 变更 账户属性

理域 Active Directory的朋友们,特别是Windows 2000的域,默认状态下没有提供工具一次性修改多个账户的属性,比如说账户的部门啊,账户的“登录到……”啊等等,用下面这个脚本就可以很方便的修改了,这个脚本支持域范围内的遍历,也就是说,您可以对整个域实施变更账户属性的操作。

Retrieve information from the user
strDN = InputBox("Enter the DN to the container you want to be the root of the search.  (Ex. OU= test,DC=Domain,DC=Com)", "Enter DN:")
strAttrib = InputBox("Enter the attribute you wish edit.  (Ex. profilePath, or homeDirectory)", "Enter Attribute")
strExQuery = InputBox("Enter additional query parameters.", "Enter Query Parameters")
strNewValue = InputBox("Enter new value for the attribute.", "Enter New Value")
Create instance of the ADO object to perform AD searches
Set con = CreateObject("ADODB.Connection")
con.Provider = "ADsDSOObject"
con.Open "Active Directory Provider"Set Query syntax
Set Command = CreateObject("ADODB.Command")
Set Command.ActiveConnection = con
Command.CommandText = "<;(&(objectCategory=person)"&strExQuery&");AdsPath">LDAP://"&strDN&">;(&(objectCategory=person)"&strExQuery&");AdsPath, cn; subTree"Set rs = Command.ExecuteEdit attribs of the returned objects
While Not rs.EOF
   Set User = GetObject(rs.Fields("AdsPath").Value)
   Set regEx = New RegExp
   regEx.Pattern = "%username%"
   regEx.Global = True
   regEx.IgnoreCase = True
   If strNewValue = "" Then
     User.PutEx ADS_PROPERTY_CLEAR, strAttrib, vbNull
   Else
     User.Put strAttrib, regEx.Replace(strNewValue, User.sAMAccountName)
   End If
   User.SetInfo
   rs.MoveNext
Wend





喜欢这篇文章吗?那就点击 订阅吧

首页| 评论 2 | 引用 1 | 编辑 按下键盘Ctrl+D会有惊喜发生
原文:批量修改ad帐户属性
分类:[首页]>>[系统管理脚本]
原创: 活动目录SEO博客版权所有。转载时必须注明本声明,本文作者和链接。
作者: gnaw0725
链接:http://gnaw0725.blogbus.com/logs/4888476.html
时间:2006-08-16 10:32
收藏到: Yahoo书签 百度收藏 Google书签 QQ书签 天极网摘 新浪ViVi 365Key网摘 diglog 和讯网摘 博拉网 Del.icio.us POCO网摘 Windows Live

一篇日志:<<  About domain naming strategies
一篇日志:将日期转换为数值型  >>


『批量修改ad帐户属性 我想说:』
 姓名: 
 网址: 
 

本页精品文章:批量修改ad帐户属性
活动目录SEO博客公告
月流量突破 10 万,总流量突破170万,如果您对活动目录域网络管理也有心得,并且希望以此扩大自己影响力,只需要添加本站链接,然后将文章标题和链接在线留言给活动目录博客,活动目录博客将收录您的文章,并注明您的站点及链接。