我的一亩三分地 我就喜欢!
13fen  设为主页
 收藏本站
 
当前位置: > 一亩三分地:首页 > 操作系统 > 服务器 > 域服务器 > 在NT移植期间改变用户帐户的属性
热门文章排行
热门文章排行 启动与关闭服务器(12-28)
服务器应用:用serv-u建立FTP一(11-16)
破解局域网内不能互访的六大经典问题(12-28)
Windows中IIS内FTP服务器高级配置(11-16)
怎样设置域名的DNS服务器(11-16)
精采文章排行
精采文章排行 在Windows Server 2003中为Web站点(11-16)
IP基础--DNS协定(11-16)
怎样设置域名的DNS服务器(11-16)
DNS—bind安装与配置的关键技术揭秘(11-16)
Exchange Server 服务器通讯端口(11-16)
技术专题推荐
网管论坛交流
 

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

作者:   来源:Linux 宝库   点击:   日期:2006-12-28



  在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







文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【论坛讨论

   相关文章:
·Win2003下Exchange2003安装全图解二 ·处理外部邮件的Exchangeserver设置
·准备好升级你的Exchange2003 ·Exchange2000安装的系统需求
·安装秘诀:Exchange2000容量与拓朴计算器 ·安装秘诀:将现有的Exchange2000群集节点

   文章评论:(条)
  
 请留名: 匿名评论   点击查看所有评论 网管论坛
 

  责任编辑:一分  声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。