Dim FileSystem
'Initialize global variables
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("email.txt", True)
Set oContainer=GetObject("LDAP://OU=Department Users,DC=MyDomainName,DC=com")
'Enumerate Container
EnumerateUsers oContainer
'Clean up
OutPutFile.Close
Set FileSystem = Nothing
Set oContainer = Nothing
WScript.Echo "Finished"
WScript.Quit(0)
Sub EnumerateUsers(oCont)
Dim oUser
For Each oUser In oCont
Select Case LCase(oUser.Class)
Case "user"
OutPutFile.WriteLine oUser.givenname & " " & oUser.sn & vbtab & oUser.mail
Case "organizationalunit" , "container"
EnumerateUsers oUser
End Select
Next
End Sub
ถ้าอยากรู้ว่า oUser (User Class) มี property อะไรบ้าง ดูตามนี้เลยครับ ไม่แน่ใจว่าครบหรือเปล่านะ
'// User Property
'SamAccountName = oUser.samAccountName
'Cn = oUser.CN
'FirstName = oUser.GivenName
'LastName = oUser.sn
'initials = oUser.initials
'Descrip = oUser.description
'Office = oUser.physicalDeliveryOfficeName
'Telephone = oUser.telephonenumber
'EmailAddr = oUser.mail
'WebPage = oUser.wwwHomePage
'Addr1 = oUser.streetAddress
'City = oUser.l
'State = oUser.st
'ZipCode = oUser.postalCode
'Title = oUser.Title
'Department = oUser.Department
'Company = oUser.Company
'Manager = oUser.Manager
'Profile = oUser.profilePath
'LoginScript = oUser.scriptpath
'HomeDirectory = oUser.HomeDirectory
'HomeDrive = oUser.homeDrive
'AdsPath = oUser.Adspath
'LastLogin = oUser.LastLogin
ไม่มีความคิดเห็น:
แสดงความคิดเห็น