What is the simplest way to get the NT-ID of a user in a C# application? I would probably need to get it only having a name of the user, or maybe an email address.
+1
A:
From within SharePoint, you can get a user's Active Directory information (including display name and email) using SPUtility.ResolveWindowsPrincipal:
For example:
SPPrincipalInfo pi = SPUtility.ResolveWindowsPrincipal(SPContext.Current.Site.WebApplication, "MYDOMAIN\\myusername", SPPrincipalType.All, false);
Outside of SharePoint, you want to look at the System.DirectoryServices namespace.
DylanW
2008-11-18 03:49:13
+3
A:
Most of the time, you can get it from the current web, for example:
string login = SPContext.Current.Web.CurrentUser.LoginName
string mail = SPContext.Current.Web.CurrentUser.Email
Nico
2008-11-18 09:02:33