JoinDomainOrWorkgroup Method of the Win32.doc

上传人:pu****.1 文档编号:545704393 上传时间:2023-06-28 格式:DOC 页数:6 大小:30.10KB
返回 下载 相关 举报
JoinDomainOrWorkgroup Method of the Win32.doc_第1页
第1页 / 共6页
JoinDomainOrWorkgroup Method of the Win32.doc_第2页
第2页 / 共6页
JoinDomainOrWorkgroup Method of the Win32.doc_第3页
第3页 / 共6页
JoinDomainOrWorkgroup Method of the Win32.doc_第4页
第4页 / 共6页
JoinDomainOrWorkgroup Method of the Win32.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《JoinDomainOrWorkgroup Method of the Win32.doc》由会员分享,可在线阅读,更多相关《JoinDomainOrWorkgroup Method of the Win32.doc(6页珍藏版)》请在金锄头文库上搜索。

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

2、( 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 pas

3、sword 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 e

4、xample, 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 const

5、ant 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

6、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 upg

7、rade 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 (0x10

8、0)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 spec

9、ified 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 cal

10、ling 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 m

11、ore 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 Settin

12、g 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

13、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

14、INSTALL_INVOCATION = 262144strDomain = FABRIKAMstrPassword = ls4k5ywAstrUser = shenalanSet objNetwork = CreateObject(WScript.Network)strComputer = objNetwork.ComputerNameSet objComputer = _ GetObject(winmgmts:impersonationLevel=Impersonate! & _ strComputer & rootcimv2:Win32_ComputerSystem.Name= _ &

15、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 Co

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号