<p>I'm writing a web application which uses windows authentication and I can happily get the user's login name using something like:</p>

<pre><code> string login = User.Identity.Name.ToString();
</code></pre>

<p>But I don't need their login name I want their DisplayName. I've been banging my head for a couple hours now...</p>

<p>Can I access my organisation's AD via a web application?</p>

See related question:
Active Directory: Retrieve User information
See also:
Howto: (Almost) Everything In Active Directory via C#
and more specifically section "
Enumerate an object's properties
".
If you have a path to connect to a group in a domain, the following snippet may be helpful:
```
```
GetUserProperty("<myaccount>", "DisplayName");

public static string GetUserProperty(string accountName, string propertyName)
{
    DirectoryEntry entry = new DirectoryEntry();
    // "LDAP://CN=<group name>, CN =<Users>, DC=<domain component>, DC=<domain component>,..."
    entry.Path = "LDAP://...";
    entry.AuthenticationType = AuthenticationTypes.Secure;

    DirectorySearcher search = new DirectorySearcher(entry);
    search.Filter = "(SAMAccountName=" + accountName + ")";
    search.PropertiesToLoad.Add(propertyName);

    SearchResultCollection results = search.FindAll();
    if (results != null && results.Count > 0)
    {
        return results[0].Properties[propertyName][0].ToString();
    }
    else
    {
            return "Unknown User";
    }
}
```
```