/// <summary> /// Gets Active Directory user by username /// </summary> /// <param name="userName"></param> /// <param name="domainId"></param> /// <returns></returns> public ADUser GetUser(string userName, int domainId) { AD_DOMAINS domain = _adDomainsDal.GetById(domainId); if (domain == null) { throw new Exception("Domain is not found"); } ADUser user = null; try { using (var ctx = new PrincipalContext(ContextType.Domain, domain.DOMAIN_NAME, domain.DOMAIN_REQUEST_LOGIN, domain.DOMAIN_REQUEST_PASSWORD)) { UserPrincipal qbeUser = new UserPrincipal(ctx); qbeUser.SamAccountName = userName; qbeUser.Enabled = true; PrincipalSearcher srch = new PrincipalSearcher(qbeUser); UserPrincipal upr = srch.FindOne() as UserPrincipal; if (upr != null && upr.Enabled.HasValue && upr.Enabled == true) { DirectoryEntry de = upr.GetUnderlyingObject() as DirectoryEntry; if (de != null) { user = CreateUserFromDirectoryEntry(de); } } } } catch { throw; } return(user); }
//查询 public T GetById(int id) { return(curDal.GetById(id)); }
public List <Brand> GetById(int id) => _brandDal.GetById(id);
public List <Color> GetById(int id) => _colorDal.GetById(id);
public List <Car> GetById(int id) => _carDal.GetById(id);
public void Delete(long id) { var entity = _baseDal.GetById(id); _baseDal.Delete(entity); }