private bool UserAuthenticate() { USER user = USERS.Entities.FirstOrDefault(x => x.NAME == UserName); if (user == null) { ShowError(false, "Username not found"); return(false); } else { if (user.GUID_ROLE == Guid.Empty) { ShowError(false, "No role assigned on user"); return(false); } if (UserName != null && UserPassword != null) { if (ActiveDirectory.Authenticate(UserName, UserPassword)) { ShowError(false, null); ShowError(true, null); XMLHelpers.UpdateSettingsXML(new XMLSettings() { Username = UserName.Trim() }); return(true); } else { SetUsernamePasswordError(); XMLHelpers.UpdateSettingsXML(new XMLSettings() { Username = string.Empty }); return(false); } } else { return(false); } } }