с использованием контекста Xrm с SDK
public Xrm.systemuser CurrentUser {
get
{
var context = new XrmDataContext();
var reponse = context.UsingService(
service => (WhoAmIResponse)service.Execute(new WhoAmIRequest()));
return (from user in context.systemusers
where user.systemuserid == reponse.UserId
select user).Single();
} }
или с веб-сервисами (здесь называемыми «crm»)
public systemuser CurrentUser
{
get
{
WhoAmIRequest userRequest = new WhoAmIRequest();
WhoAmIResponse current = (WhoAmIResponse)crm.Execute(userRequest);
return (systemuser)crm.Retrieve(EntityName.systemuser.ToString(), current.UserId, new AllColumns());
}
}