首页 系统管理脚本 管理 活动目录域管理 变更 账户属性
管理域 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
收藏到:
上一篇日志:<< About domain naming strategies
下一篇日志:将日期转换为数值型 >>
|