Maystyle :
Admin : New post
Guestbook
Local
media
Catergories
Recent Articles
Recent Comments
Recent Trackbacks
Calendar
Tag
Archive
Link
Search
 
  DN 리스트가 저장된 Text 파일을 읽어 그룹에 등록시키는 스크립트 
작성일시 : 2008. 2. 21. 17:35 | 분류 : Windows Server/Active Directory

이전 포스트(http://maystyle.tistory.com/274)에서 작성된 text 파일을 읽어서 그룹에 추가하는 스크립트 입니다.

On Error Resume next

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\userlist.txt", 1)

Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    Const ADS_PROPERTY_APPEND = 3

    Set objGroup = GetObject _
        (LDAP://cn=그룹명, cn=Users, dc=xxx, dc=xxx, dc=xxx)
    objGroup.PutEx ADS_PROPERTY_APPEND, _
        "member", Array (strLine)
    objGroup.SetInfo

Loop

objFile.Close
WScript.Echo ("Script Completed")

실제로 응용하자면

    Const ADS_PROPERTY_APPEND = 3

    Set objGroup = GetObject _
        (LDAP://cn=그룹명, cn=Users, dc=xxx, dc=xxx, dc=xxx)
    objGroup.PutEx ADS_PROPERTY_APPEND, _
        "member", Array (strLine)
    objGroup.SetInfo

위의 부분에 각종 작업을 넣어 줄 수 있습니다.
전 사용자를 등록하는 작업을 넣었습니다.
즉 각 라인인 str 라인으로 하는 모든 작업이 가능해 집니다.

|