CTOCIO IT专家网

天极传媒 比特网 | 天极网 | IT专家网 | IT商网 | 52PK游戏网 | 手机天极 | IT分众 |
IT专家网搜索

您现在的位置: IT专家网 > WinSystem子站 > 技巧

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

作者: Greg Peters,  出处:TechTarget, 责任编辑: Harte, 
2005-08-29 09:03
  在把用户从NT的备份域控制器向Windows 2000移植的过程中,我们需要改变用户的资料档案的路径。这个脚本是由其它的代码的片断以及一些巧妙的方法综合而成的。这使得修改其它用户的属性变得相当容易。

  在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

网友评论

笔名 
请您注意:遵守国家有关法律、法规,尊重网上道德,承担一切因您的行为而直接或间接引起的法律责任。    IT专家网友拥有管理笔名和留言的一切权利。
  • 周排行榜
  • 月排行榜

邮件订阅

该文章的读者还阅读了

天极服务 | 关于我们 | 网站律师 | 加入我们 | 联系我们 | 广告业务 | 友情链接 | 我要挑错
All Rights Reserved, Copyright 2004-2008, Ctocio.com.cn
渝ICP证B2-20030003号 如有意见请与我们联系 powered by 天极内容管理平台CMS4i