[shell] window 2000 AD 대량 계정 추가
클래식 작업중에 만든 스크립트를 약간 변경했습니다. 복수 계정을 원빵에 셋업할때 쓸
만한 스크립트입니다.
접두어와 인원수만 입력해주면 한꺼번에 설정대로 계정을 생성합니다.
다음의 내용을 batch_setup.vbs라는 이름으로 저장한 후 active directory가 있는 기계
에서 수행해보세요.
[내용 시작]
On Error Resume Next
Const CLASSIC_DOMAIN = “dc=MANPA,dc=WTS”
Const DEFAULT_DESCRIPTION = “Manpa user”
Const STUDENT_PROFILE = “\\\\wts2\\home\\pc_class\\pc_profile\\%
username%”
Const STUDENT_HOME = “\\\\wts2\\home\\pc_class\\pc_user\\%username%”
Const STUDENT_HOME_DRIVE = “F:”
Const MASTER_PROFILE = “\\\\wts2\\home\\ms_class\\ms_profile\\%
username%”
Const MASTER_HOME = “\\\\wts2\\home\\ms_class\\ms_user\\%username%”
Const MASTER_HOME_DRIVE = “F:”
Const STUDENT_GROUP = “LDAP://cn=students,ou=student,dc=MANPA,dc=WTS”
Const MASTER_GROUP = “LDAP://cn=masters,ou=master,dc=MANPA,dc=WTS”
Dim adsDomain, Prefix, Population
Set adsDomain = GetObject(“LDAP://ou=student,” & CLASSIC_DOMAIN)
Prefix = InputBox(“Enter prefix”, “Prefix”)
Population = InputBox(“Enter population”, “Population”)
‘Set Prefix = Request.QueryString(“prefix”)
‘Set Population = Request.QueryString(“popl”)
Dim i, pLen, iLen, Account
pLen = Len(Population)
For i = 1 To Population
iLen = Len(i)
Account = Prefix & String(pLen-iLen, “0”) & i
AddStudent Account
Next
MsgBox “Done!”
Sub AddStudent(username)
Set adsUser = adsDomain.Create(“user”,”cn=” & username)
adsUser.Put “sAMAccountName”, username
adsUser.Put “userPrincipalName”, username
‘Write the newly created object out from the property cache
adsUser.SetInfo
‘Read all the properties for the object, including
‘the ones set by the system on creation
adsUser.GetInfo
adsUser.AccountDisabled = False
adsUser.Description = DEFAULT_DESCRIPTION
adsUser.IsAccountLocked = False
adsUser.Profile = STUDENT_PROFILE
‘adsUser.LoginScript = STUDENT_LOGIN
adsUser.PasswordRequired = True
‘adsUser.NamePrefix = “”
‘adsUser.FirstName = “”
‘adsUser.LastName = “”
adsUser.DisplayName = username
‘Set the drive that you’ll map to.
adsUser.HomeDirectory = STUDENT_HOME & username
adsUser.Put “homeDrive”, STUDENT_HOME_DRIVE
‘Set all the properties for the user
adsUser.SetInfo
adsUser.SetPassword “”
‘Add to students group
Set adsGroup = GetObject(STUDENT_GROUP)
adsGroup.Add(adsUser.ADsPath)
End Sub