Search code examples
c#.netwindows-identity

Get Windows LiveID by first and last name


in my company, we're using MS Outlook and Skype. In both applications, I can click on several user to get information about them like the first name, the last name, availability, email adress or the information of WindowsIdentification.Name (i think, this is called the Live ID).

enter image description here It looks like in the picutrue. I just erased personal information from the picture.

Is there a possibility to request this information of any user by their first and last name?

What I'm searching for is the function:

/*This function exists*/
System.Security.Principal.WindowsIdentity.GetCurrent().Name;

But I don't want to know my own LiveID but the ID from some other user. So, I need something like:

/*This function does not exists*/
string UID = System.Security.Principal.WindowsIdentity.GetByName("Max Mustermann").Name;
Console.WriteLine(UID) /*prints DomainName/UserID*/

Is something like that available in .NET?


Solution

  • You can use the DirectorySeacher class to do this.

    For example:

    DirectorySearcher searcher1 = new DirectorySearcher(entry);
    searcher1.Filter = string.Format("(&(objectCategory=person)(objectClass=user)(givenname={0})(sn={1}))", aName, aSName);
    
    SearchResultCollection results1;
    results1 = searcher1.FindAll();