When we log into our Windows computers, we use "CORP \ username".
Given the SID of the user and the domain controller where they logged in, how can I get this line? I am using DirectoryServices APIs added in .NET 3.5, for example:
PrincipalContext domaincontroller = new PrincipalContext(ContextType.Domain, "192.168.30.115");
UserPrincipal user = UserPrincipal.FindByIdentity(domaincontroller, IdentityType.Sid, "S-1-5-21-293182769-1777760488-2957165303-1798");
I dug up the domaincontroller object and the user object and saw a lot of things like this:
user.Name: john smith
user.DisplayName: john smith
user.UserPrincipalName: john.smith@corp.mycompany.com
user.SamAccountName: john.smith
If I delve into the private brushes of the UserPrinciple object, I find two fields labeled "domainFlatName" and "FlatDomainName" that contain exactly what I want (screenshot below). What does this mean and how can I get to them through an open interface?

source