JoinDomainOrWorkgroup of the Win32.doc_第1页
JoinDomainOrWorkgroup of the Win32.doc_第2页
JoinDomainOrWorkgroup of the Win32.doc_第3页
JoinDomainOrWorkgroup of the Win32.doc_第4页
JoinDomainOrWorkgroup of the Win32.doc_第5页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

JoinDomainOrWorkgroup Method of the Win32_ComputerSystem ClassThe JoinDomainOrWorkgroup method joins a computer system to a domain or workgroup.This topic uses Managed Object Format (MOF) syntax. For more information about using this method, seeCalling a Method.SyntaxCopyuint32 JoinDomainOrWorkgroup( in string Name, in string Password, in string UserName, in, optional string AccountOU, in uint32 FJoinOptions = 1);ParametersName inSpecifies the domain or workgroup to join. Cannot be NULL.Password inIf the UserName parameter specifies an account name, the Password parameter must point to the password to use when connecting to the domain controller. Otherwise, this parameter must be NULL. UserName inPointer to a constant null-terminated character string that specifies the account name to use when connecting to the domain controller. Must specify a domain NetBIOS name and user account, for example, Domainuser. If this parameter is NULL, the caller information is used.You can also use the user principal name (UPPED) in the form userdomain.Windows 2000, Windows NT 4.0, and Windows Me/98/95: You cannot specify UserName in UPPED format.AccountOU in, optionalSpecifies the pointer to a constant null-terminated character string that contains the RFC 1779 format name of the organizational unit (OU) for the computer account. If you specify this parameter, the string must contain a full path, otherwise Accent must be NULL. Example: OU=testOU, DC=domain, DC=Domain, DC=comFJoinOptions inSet of bit flags that define the join options.ValueMeaning1 (0x1)Default. Joins a computer to a domain. If this value is not specified, the join is a computer to a workgroup.2 (0x2)Creates an account on a domain.4 (0x4)Deletes an account when a domain exists.16 (0x10)The join operation is part of an upgrade from Windows 98 or Windows 95 to Windows 2000 or Windows NT.32 (0x20)Allows a join to a new domain, even if the computer is already joined to a domain.64 (0x40)Performs an unsecured join.128 (0x80)The machine, not the user, password passed. This option is only valid for unsecure joins.256 (0x100)Writing SPN and DnsHostName attributes on the computer object should be deferred until the rename that follows the join.262144 (0x40000)The APIs were invoked during install. Return ValueReturn code/valueDescription0SuccessWBEM_E_ENCRYPTED_CONNECTION_REQUIRED0x80041087Password and UserName are specified but the authentication level is not RPC_C_AUTHN_LEVEL_PKT_PRIVACY. For Visual Basic, wbemErrEncryptedConnectionRequired is returned.RemarksWhen moving a computer from a domain to a workgroup, you must remove the computer from the domain before calling this method to join a workgroup. After calling this method, restart the affected computer to apply the changes. UserName and Password can be left null. However, the authentication of the connection to WMI must be 6 in script or WbemAuthenticationLevelPktPrivacy in Visual Basic and other languages that can use the wbemdisp.dll library. For more information, see Setting the Default Process Security Level Using VBScript.In C+, set the authentication at RPC_C_AUTHN_LEVEL_PKT_PRIVACY either in CoInitializeSecurity, for the entire process, or in CoSetProxyBlanket, for a connection to the IWbemServices proxy. For more information, see Setting Authentication Using C+ and Setting the Security on IWbemServices and Other Proxies.ExamplesFor script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.For C+ code examples, see WMI C+ Application Examples.The following VBScript code example joins a computer to a domain and creates the computers account in Active Directory. CopyConst JOIN_DOMAIN = 1Const ACCT_CREATE = 2Const ACCT_DELETE = 4Const WIN9X_UPGRADE = 16Const DOMAIN_JOIN_IF_JOINED = 32Const JOIN_UNSECURE = 64Const MACHINE_PASSWORD_PASSED = 128Const DEFERRED_SPN_SET = 256Const INSTALL_INVOCATION = 262144strDomain = FABRIKAMstrPassword = ls4k5ywAstrUser = shenalanSet objNetwork = CreateObject(WScript.Network)strComputer = objNetwork.ComputerNameSet objComputer = _ GetObject(winmgmts:impersonationLevel=Impersonate! & _ strComputer & rootcimv2:Win32_ComputerSystem.Name= _ & strComputer & )ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _ strPassword, _ strDomain & & strUser, _ NULL, _ JOIN_DOMAIN + ACCT_CREATE)RequirementsMinimum supported clientWindows XPMinimum supported serverWindows Server 2003MOFCimwin32.mofDLLCimwin32.dllNamespacerootcimv2See AlsoWin32_ComputerSystemSend comments about this topic to MicrosoftBuild date: 6/2/2011Community ContentAddFAQSyntax Big thanks to Jasen on this one!Just to reiterate, as Jasen pointed out, the syntax for the AccountOU parameter requires semicolons as delimiters, not commas as in the example. strOU = OU=testOU; DC=domain; DC=Domain; DC=comReturnValue = objComputer.JoinDomainOrWorkGroup (Domain, _ Password, _ Domain & & Username, _strOU, _ JOIN_DOMAIN + ACCT_CREATE)Obviously, using commas will give you a ReturnValue of 87 which is the The parameter is incorrect System Error.History 3/17/2010 RunningGag wmic.exe - cool command line wmi tool I spent days trying to figure out how to use wmic.exe to join the domain. The biggest key was figuring out the syntax as there are a couple of different ways to do it. Importantly, if you specify the AccountOU, you must use the DN as mentioned above. What it fails to mention is that WMIC uses commas (,) to separate paramaters and will cause WMIC to fail. You must use semicolons (;) in your DN instead. Example: OU=testOU; DC=domain; DC=Domain; DC=com Command Line examples1. wmic.exe /interactive:off ComputerSystem Where name = %computername% call JoinDomainOrWorkgroup AccountOU=OU=XP Workstations;DC=my;DC=domain;DC=com FJoinOptions=1 Name= Password=xyz UserName= 2. wmic.exe /interactive:off ComputerSystem Where name = %computername% call JoinDomainOrWorkgroup OU=XP Workstations;DC=my;DC=domain;DC=com, 1, , xyz, Both work, but the first one is easier to edit and the parameters can be in a different order.History 3/11/2010 Jasen Webster 3/11/2010 Jasen WebsterError message listing Hi, The error codes are Windows system error codes,You can find the listing here : /en-us/library/ms681382(VS.85).aspxHistory 9/3/2009 JoeSatch Error message listing Not sure why, but this article doesnt tell you about the error return values. This one does, and the constants are repeated below:http:/cwashi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论