I need to log in to the user on my system, with the user logged in to the company network. I've never done this and am having second thoughts on how to get user in AD. I am doing research on the net and still can not understand how to search for this user. The question is: How do I get the user logged on to the network and soon on my system? I use MVC5, Visual Studio 2013, C #.
So, I got this code in another forum and it worked, but there is one boring thing still to be solved. It brings me the domain and / or machine name, in this format: Domain \ User. How do I remove the domain and the forward slash? Below is my solution:
public ActionResult CadastroCargo()
{
ViewBag.User = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
return View();
}