广告
返回顶部
首页 > 资讯 > 精选 >如何利用VBS脚本自动创建计算机帐户
  • 302
分享到

如何利用VBS脚本自动创建计算机帐户

2023-06-08 14:06:27 302人浏览 安东尼
摘要

本篇内容主要讲解“如何利用VBS脚本自动创建计算机帐户”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“如何利用VBS脚本自动创建计算机帐户”吧!mcse注:其实这是 按照ADSI(Act

本篇内容主要讲解“如何利用VBS脚本自动创建计算机帐户”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“如何利用VBS脚本自动创建计算机帐户”吧!

mcse注:其实这是 按照ADSI(Active Directory Services Interface:活动目录服务接口)写的程序。如果你安装了resource kit,这段代码可以用netcom这条命令进行工作,下面是netcom的一个例子: 

  NETDOM /Domain:MYDOMAIN /user:adminuser /passWord:apassword MEMBER MYCOMPUTER /ADD 

复制代码 代码如下:


  ***********************

  '* Start Script

  '***********************

  Dim sComputerName, sUserOrGroup, sPath, computerContainer, rootDSE, lFlag

  Dim secDescriptor, dACL, ACE, oComputer, sPwd

  '

  '* Declare constants used in defining the default location for the

  '* Machine account, flags to identify the object as a machine account,

  '* and security flags

  'Const UF_WORKSTATION_TRUST_ACCOUNT = &H1000

  Const UF_ACCOUNTDISABLE = &H2

  Const UF_PASSWD_NOTREQD = &H20

  Const ADS_GUID_COMPUTRS_CONTAINER = "aa312825768811d1aded00c04fd8d5cd"

  Const ADS_ACETYPE_ACCESS_ALLOWED = 0

  Const ADS_ACEFLAG_INHERIT_ACE = 2

  '

  '* Set the flags on this object to identify it as a machine account

  '* and determine the name. The name is used statically here, but may

  '* be determined by a command line parameter or by using an InputBox

  'lFlag = UF_WORKSTATION_TRUST_ACCOUNT Or UF_ACCOUNTDISABLE Or UF_PASSWD_NOTREQD

  sComputerName = "TestAccount"

  '

  '* Establish a path to the container in the Active Directory where

  '* the machine account will be created. In this example, this will

  '* automatically locate a domain controller for the domain, read the

  '* domain name, and bind to the default "Computers" container

  '*********************************************************************

  Set rootDSE = GetObject("LDAP://RootDSE")

  sPath = "LDAP://  Set computerContainer = GetObject(sPath)

  sPath = "LDAP://" & computerContainer.Get("distinguishedName")

  Set computerContainer = GetObject(sPath)

  ''* Here, the computer account is created. Certain attributes must

  '* have a value before calling .SetInfo to commit (write) the object

  '* to the Active Directory

  'Set oComputer = computerContainer.Create("computer", "CN=" & sComputerName)

  oComputer.Put "samAccountName", sComputerName + "$"

  oComputer.Put "userAccountControl", lFlag

  oComputer.SetInfo

  '

  '* Establish a default password for the machine account

  'sPwd = sComputerName & "$"

  sPwd = LCase(sPwd)

  oComputer.SetPassword sPwd

  ''* Specify which user or group may activate/join this computer to the

  '* domain. In this example, "MYDOMAIN" is the domain name and

  '* "JoeSmith" is the account being given the permission. Note that

  '* this is the downlevel naming convention used in this example.

  'sUserOrGroup = "MYDOMAIN\joesmith"

  ''* Bind to the Discretionary ACL on the newly created computer account

  '* and create an Access Control Entry (ACE) that gives the specified

  '* user or group full control on the machine account

  'Set secDescriptor = oComputer.Get("ntSecurityDescriptor")

  Set dACL = secDescriptor.DiscretionaryAcl

  Set ACE = CreateObject("AccessControlEntry")

  '

  '* An AcceSSMask of "-1" grants Full Control

  '

  ACE.AccessMask = -1

  ACE.AceType = ADS_ACETYPE_ACCESS_ALLOWED

  ACE.AceFlags = ADS_ACEFLAG_INHERIT_ACE

  ''* Grant this control to the user or group specified earlier.

  'ACE.Trustee = sUserOrGroup

  '

  '* Now, add this ACE to the DACL on the machine account

  'dACL.AddAce ACE

  secDescriptor.DiscretionaryAcl = dACL

  '

  '* Commit (write) the security changes to the machine account

  'oComputer.Put "ntSecurityDescriptor", Array(secDescriptor)

  oComputer.SetInfo

  ''* Once all parameters and permissions have been set, enable the

  '* account.

  '

  oComputer.AccountDisabled = False

  oComputer.SetInfo

  ''* Create an Access Control Entry (ACE) that gives the specified user

  '* or group full control on the machine account

  'wscript.echo "The command completed successfully."

  '*****************

  '* End Script


到此,相信大家对“如何利用VBS脚本自动创建计算机帐户”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

--结束END--

本文标题: 如何利用VBS脚本自动创建计算机帐户

本文链接: https://www.lsjlt.com/news/254508.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 如何利用VBS脚本自动创建计算机帐户
    本篇内容主要讲解“如何利用VBS脚本自动创建计算机帐户”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“如何利用VBS脚本自动创建计算机帐户”吧!mcse注:其实这是 按照ADSI(Act...
    99+
    2023-06-08
  • shell脚本如何自动创建用户
    这篇文章主要为大家展示了“shell脚本如何自动创建用户”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“shell脚本如何自动创建用户”这篇文章吧。shell脚本 自动创建用户详解需求:判断用户z...
    99+
    2023-06-09
  • shell脚本自动化如何创建虚拟机
    这篇文章主要介绍了shell脚本自动化如何创建虚拟机,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。自动化shell脚本ps:此处安装的jdk,maven,tomcat均在/o...
    99+
    2023-06-09
  • 使用VBS脚本如何收集远程计算机或本地计算机安装的软件
    使用VBS脚本如何收集远程计算机或本地计算机安装的软件?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。制作VBS脚本保存下面的VBS程序代码到vbs文件中On Er...
    99+
    2023-06-06
  • 如何实现xp、2003开3389+非net创建管理用户+Shift后门+自删除的vbs脚本
    这篇文章主要介绍了如何实现xp、2003开3389+非net创建管理用户+Shift后门+自删除的vbs脚本,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。代码如下:on&nb...
    99+
    2023-06-08
  • 如何利用计划任务和VBS脚本实现自动WEB共享文件夹里的文件
    这篇文章主要介绍如何利用计划任务和VBS脚本实现自动WEB共享文件夹里的文件,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!代码如下:Option Explicit On Error Resume Next '...
    99+
    2023-06-08
  • 本地计算机怎么使用代理服务器以及如何自动设置代理
    本篇内容介绍了“本地计算机怎么使用代理服务器以及如何自动设置代理”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!本地计算机如何使用代理服务器方...
    99+
    2023-06-20
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作