private User LoginActiveDirectory(string username, string password) { if (ADController.TryLogin(username, password)) { var user = Core.UserManager.GetUser2(username); if (user == null) { user = new User { Username = username, RealName = username.GetDisplayName(), GroupID = Core.UserManager.GetGroupID(username.GetGroupName()) }; Core.UserManager.Save(user); } return(user); } return(null); }