注册
 找回密码
 注册
江西广告网
查看: 284|回复: 0
打印 上一主题 下一主题

在NT移植期间改变用户帐户的属性

[复制链接]

该用户从未签到

1
跳转到指定楼层
发表于 2009-1-2 11:36:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?注册

x
  在NT移植期间改变用户帐户的属性      在把用户从NT的备份域控制器向Windows 2000移植的过程中,我们需要改变用户的资料档案的路径。这个脚本是由其它的代码的片断以及一些巧妙的方法综合而成的。这使得修改其它用户的属性变得相当容易。      ===================================================   ' Name: moduser.vbs   ' Description: Modify profile path of user accounts.      Only those with a current roaming profile are udpated.   ' Original: 13 Jun 05   '   '=================================================      Set objConnection = CreateObject("ADODB.Connection")      objConnection.Open "Provider=ADsDSOObject;"      Set objCommand = CreateObject("ADODB.Command") objCommand.ActiveConnection = objConnection      WScript.StdOut.WriteLine "Enter search criteria.      Wildcards can be used."   strUserName = WScript.StdIn.ReadLine   WScript.Echo      objCommand.CommandText = _   "<LDAP://dc=,dc=>;"      & _ "(&(objectCategory=user)(sAMAccountName=" & strUserName & "));" & _      "sAMAccountName,profilePath,ADsPath;subtree"      Set objRecordSet = objCommand.Execute      If objRecordset.EOF Then   Wscript.Echo "No user account(s) found with the specified criteria."   Else   Wscript.Echo "User account(s) with the specified criteria:"   While Not objRecordset.EOF   Wscript.Echo objRecordset.Fields("sAMAccountName") & " : " & _   objRecordset.Fields("profilePath")   objRecordset.MoveNext   WEnd   End If   WScript.Echo      strNewProfPath = ""   While strNewProfPath = ""   WScript.StdOut.WriteLine "Enter new profile server and share: "   StrNewProfPath = WScript.StdIn.ReadLine WEnd WScript.Echo      ' Refresh record set to apply new path.   Set objRecordSet = objCommand.Execute      While Not objRecordset.EOF   If IsNull(objRecordSet.Fields("profilePath")) Then   WScript.Echo objRecordSet.Fields("sAMAccountName") & " has no roaming profile."   WScript.Echo   Else   strADsPath = objRecordSet.Fields("ADsPath")   Set objUser = GetObject(strADsPath)   objUser.Put "profilePath", strNewProfPath & "" & _   objRecordset.Fields("sAMAccountName") & ".USR"   objUser.SetInfo   End If   objRecordset.MoveNext   WEnd      ' Refresh record set to view new profile path.   Set objRecordSet = objCommand.Execute      WScript.Echo "User account(s) with the new target data:"   While Not objRecordset.EOF   'WScript.Echo objRecordSet.Fields("profilePath")   If objRecordSet.Fields("profilePath") <> " " Then   Wscript.Echo objRecordset.Fields("sAMAccountName") & " : " & _   objRecordset.Fields("profilePath")   End If   objRecordset.MoveNext   WEnd      objConnection.Close <
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表