반응형
Windows 2000 에서 컴퓨터 계정 생성을 자동화 하기
본 문서의 정보는 다음의 제품에 적용됩니다.
Microsoft Windows 2000 Professional
Microsoft Windows 2000 Server
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Datacenter Server
요약본 문서는 컴퓨터 계정 생성을 자동화 하는 두 가지 방법을 설명하고 있습니다.
- NETDOM (a Windows 2000 Resource Kit tool)
- ADSI 와 Windows Script Host 를 이용한 컴퓨터 계정 Scripting
추가 정보NETDOM 을 이용한 컴퓨터 계정 만들기
주의: Windows 2000 Resource Kit 에 포함되어 있는 Windows 2000 버전의 NETDOM만이 사용되어야 합니다. 이전의 버전은 Windows 2000 의 모든 기능에 대해서 올바르게 작동하지 않습니다.
아래에 나열되어 있는 문구를 이용하여 명령 라인(또는 선택적으로 batch 파일에서 호출하여)에서 NETDOM을 사용하여 컴퓨터 계정 생성을 할 수 있습니다. 이 샘플은 컴퓨터 계정만을 생성하고 도메인 내에서 컴퓨터 계정을 생성하는 권한을 가진 인증된 사용자 자격이 어떻게 지정될 수 있는지에 대해서 보여주고 있습니다.
NETDOM /Domain:MYDOMAIN /user:adminuser /password:apassword MEMBER MYCOMPUTER/ADD
NETDOM 사용에 대한 추가 정보를 보시려면 Microsoft Knowledge Base 에 있는 다음 문서를 참고하시기 바랍니다:
Q150493 How To Join a Domain From the Command Line
ADSI 와 Windows Script Host 를 이용한 컴퓨터 계정 스크립트
Active Directory 서비스 인터페이스 (ADSI) 와 Windows Script Host (WSH) 를 이용하여 관리자는 컴퓨터 계정의 생성을 자동화하기 위한 Visual Basic Script (VBScript) 를 만들 수 있습니다.
Visual Basic Scripting 에 대한 추가 정보를 보시려면 다음의 Microsoft 웹 사이트를 방문하시기 바랍니다:
msdn.microsoft.com/scripting
이 방법을 사용하기 위해서는 아래의 샘플 스크립트에 약술되어 있는 것처럼 스크립트를 만듭니다. 그리고 나서 .vbs 확장자를 가진 파일로 저장합니다. 해당 파일을 실행하기 위해서는 그것을 두 번 누르거나 명령 프롬프트에 "cscript myscript.vbs" (인용 부호 없음) 를 입력하시기 바랍니다.
Sample Script:
'***********************
'* 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://<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 Windows 2000 Professional
Microsoft Windows 2000 Server
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Datacenter Server
요약본 문서는 컴퓨터 계정 생성을 자동화 하는 두 가지 방법을 설명하고 있습니다.
- NETDOM (a Windows 2000 Resource Kit tool)
- ADSI 와 Windows Script Host 를 이용한 컴퓨터 계정 Scripting
추가 정보NETDOM 을 이용한 컴퓨터 계정 만들기
주의: Windows 2000 Resource Kit 에 포함되어 있는 Windows 2000 버전의 NETDOM만이 사용되어야 합니다. 이전의 버전은 Windows 2000 의 모든 기능에 대해서 올바르게 작동하지 않습니다.
아래에 나열되어 있는 문구를 이용하여 명령 라인(또는 선택적으로 batch 파일에서 호출하여)에서 NETDOM을 사용하여 컴퓨터 계정 생성을 할 수 있습니다. 이 샘플은 컴퓨터 계정만을 생성하고 도메인 내에서 컴퓨터 계정을 생성하는 권한을 가진 인증된 사용자 자격이 어떻게 지정될 수 있는지에 대해서 보여주고 있습니다.
NETDOM /Domain:MYDOMAIN /user:adminuser /password:apassword MEMBER MYCOMPUTER/ADD
NETDOM 사용에 대한 추가 정보를 보시려면 Microsoft Knowledge Base 에 있는 다음 문서를 참고하시기 바랍니다:
Q150493 How To Join a Domain From the Command Line
ADSI 와 Windows Script Host 를 이용한 컴퓨터 계정 스크립트
Active Directory 서비스 인터페이스 (ADSI) 와 Windows Script Host (WSH) 를 이용하여 관리자는 컴퓨터 계정의 생성을 자동화하기 위한 Visual Basic Script (VBScript) 를 만들 수 있습니다.
Visual Basic Scripting 에 대한 추가 정보를 보시려면 다음의 Microsoft 웹 사이트를 방문하시기 바랍니다:
msdn.microsoft.com/scripting
이 방법을 사용하기 위해서는 아래의 샘플 스크립트에 약술되어 있는 것처럼 스크립트를 만듭니다. 그리고 나서 .vbs 확장자를 가진 파일로 저장합니다. 해당 파일을 실행하기 위해서는 그것을 두 번 누르거나 명령 프롬프트에 "cscript myscript.vbs" (인용 부호 없음) 를 입력하시기 바랍니다.
Sample Script:
'***********************
'* 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://<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
'*****************
반응형
'윈도우즈' 카테고리의 다른 글
무료 윈도 XP 서비스팩2 CD (0) | 2007.08.02 |
---|---|
wmiprvse.exe과 wdfmgr.exe 파일. (0) | 2007.08.02 |
sp2 시디 무료로 받는곳 (0) | 2007.08.02 |
`보내기` 메뉴에 항목 추가하기 (0) | 2007.08.02 |
윈도XP sp2에서 임시로 차단 기능 쓰지 않기 (0) | 2007.08.02 |
관리 목적 공유 폴더의 문제점 (0) | 2007.08.01 |
레지스트리최적화로 통신속도 증가시키기(ADSL이나 케이블모뎀의 경우) (0) | 2007.08.01 |
시스템 오류파일 만들기 (0) | 2007.08.01 |
실행명령어의 종류 (0) | 2007.08.01 |
윈도우 로고파일 바꾸기(98) (0) | 2007.08.01 |