Created
July 14, 2015 08:50
-
-
Save DmitriyVlasov/57279bab3d2924f06e25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "System.DirectoryServices.AccountManagement.dll" | |
open System.DirectoryServices.AccountManagement | |
let testSearch fullName = | |
let ctx = new PrincipalContext(ContextType.Domain) | |
let u = new UserPrincipal(ctx) | |
u.Surname <- fullName | |
use ps = new PrincipalSearcher(u) | |
ps.FindAll() | |
|> Seq.cast<System.DirectoryServices.AccountManagement.UserPrincipal> | |
for r in testSearch "Ivanov" do | |
printfn "DistinguishedName: %s;" r.DistinguishedName | |
printfn "Guid: %A;"r.Guid | |
printfn "Name: %s:" r.Name | |
printfn "SamAccountName: %s;" r.SamAccountName | |
printfn "Sid: %A;" r.Sid | |
printfn "UserPrincipalName: %s;" r.UserPrincipalName | |
printfn "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment