-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestFile.fs
22 lines (18 loc) · 1.03 KB
/
testFile.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// testFile.fs
let main() =
// instead of spelling out the root directory entry below, people could simply pass the directoryentry from one of the results from getAllDomainControllers method in fActiveDirectory
let userSearcher = new DirectorySearcher(new DirectoryEntry("LDAP://OU=Company,dc=ricky,dc=bobby,dc=com"), String.Format("(&(objectCategory=person)(objectClass=user))"), PageSize=10000)
let start = DateTime.Now
let users = Seq.cast (userSearcher.FindAll() )
let userLastLogons =
Async.Parallel [ for sr:SearchResult in users -> async { return (new DirectoryEntry(sr.Path), lastLogon(sr.Path)) } ]
|> Async.RunSynchronously
for user,lastLogon in userLastLogons do
let samAccount = user.Properties.["samAccountName"].Value.ToString()
let userLastLogon = lastLogon.ToString()
printfn "%s -> %s" samAccount userLastLogon
let total = DateTime.Now - start
let totalDateTime = total.ToString()
printfn "Done in %s." totalDateTime
Console.Read() |> ignore
main()