惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 热门话题
Stack Overflow Blog
Stack Overflow Blog
B
Blog
WordPress大学
WordPress大学
Project Zero
Project Zero
P
Palo Alto Networks Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - 司徒正美
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
T
Tailwind CSS Blog
Forbes - Security
Forbes - Security
F
Full Disclosure
SecWiki News
SecWiki News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hacker News: Ask HN
Hacker News: Ask HN
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
F
Fortinet All Blogs
Cisco Talos Blog
Cisco Talos Blog
G
Google Developers Blog
J
Java Code Geeks
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
O
OpenAI News
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Cybersecurity and Infrastructure Security Agency CISA
S
Securelist
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
IT之家
IT之家
U
Unit 42
腾讯CDC
S
Security Affairs
C
Cisco Blogs
Schneier on Security
Schneier on Security
The Last Watchdog
The Last Watchdog
B
Blog RSS Feed
宝玉的分享
宝玉的分享
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security @ Cisco Blogs
Cyberwarzone
Cyberwarzone
T
The Blog of Author Tim Ferriss

博客园 - Mint

I'm Back 如何分析资产负债表 - Mint - 博客园 推式与拉式生产(Push and Pull Production) {转载}PUSH-PULL集成生产管理模式在制造执行系统中的应用 ERP中财物凭证 分久必合,合久必分 理解ERP的小比喻--做大事如烹小鲜 老曹语录 Asp操作DTS进行代参数的数据导入导出 关于Access2003数据集操作的一个简单问题 无法使用Outlook 2003 Out Of Office Assisant 刷机 [团队]企业内网开发集成应用--欢迎参加 关于Infopath的3种Email发送功能 使用sysprep使计算机自动添加入域 工作流的问题 Linux 的 常 用 网 络 命 令 DOS下常用网络相关命令解释 爽哉使用cnwap手机卡在笔记本上上网
自动创建计算机帐户(转微软)
Mint · 2006-06-27 · via 博客园 - Mint

 

注意:这篇文章是由无人工介入的自动的机器翻译系统翻译完成。这些文章是微软为不懂英语的用户提供的, 以使他们能够理解这些文章的内容。微软不保证机器翻译的正确度,也不对由于内容的误译或者客户对它的使用所引起的任何直接的, 或间接的可能的问题负责。

文章编号 : 315273
最后修改 : 2006年5月4日
修订 : 3.0
本页

概要

本文介绍如何自动化创建计算机帐户。 描述两种方法:

Netdom
计算机帐户使用 ActiveDirectory 服务接口 (ADSI) 和 WindowsScriptHost 脚本

更多信息

创建使用 " NETDOM " 计算机帐户

请注意, 您应该使用它是随 WindowsXPCD Support\Tools\Support.cab 文件中只是 netdom , WindowsXP 版本。 对于 WindowsXP 中所有功能无法正常工作版本。

可用于脚本计算机帐户创建 netdom 从命令行 (或可选从批处理文件调用它)。 本示例创建计算机帐户仅并显示如何指定授权用户有权在域中创建计算机帐户的凭据。 按照此 Netdom 命令语法的示例

netdom 加入 ComputerName /domain: DomainName / userd 用户 / passwordd UserPassword ::

用户 是用户有权加入域。

有关使用 NETDOM, 请单击下列文章编号以查看 Microsoft 知识库中相应:

150493 (http://support.microsoft.com/kb/150493/) 如何从命令行加入域

脚本使用 ADSI 和 WindowsScriptHost 计算机帐户

使用 Active Directory Services Interface (ADSI) 和 Windows Script Host (WSH), 管理员可以创建一个 VisualBasic 脚本 (VBScript) 来自动化创建计算机帐户。

有关 Visual Basic Scripting, 请访问 Microsoft Web 站点:

要使用此方法, 以下示例脚本中所述创建脚本并以 .vbs 扩展名保存文件。 要运行文件, 双击文件或在命令提示符处键入 cscript myscript.vbs

示例脚本

'***********************
'* 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 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
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://<WKGUID=" & ADS_GUID_COMPUTRS_CONTAINER
sPath = sPath + ","
sPath = sPath + rootDSE.Get("defaultNamingContext")
sPath = sPath + ">"
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
'*****************
Microsoft 提供编程示例仅, 供图示不附带任何明示或暗示。 这包括, 但不仅限于, 适销性或用于特定目的适用性的暗示保证。 本文假定您已熟悉与正在演示编程语言以及工具来调试过程来创建和使用。 Microsoft 支持工程师可以帮助解释功能的特定过程, 但它们将会修改这些示例以提供添加功能或构建过程以满足特定要求。

有关 UserAccountControl 标志, 请单击下列文章编号以查看 Microsoft 知识库中相应:

305144 (http://support.microsoft.com/kb/305144/) 如何使用 UserAccountControl 标志来操纵用户帐户属性