コード例 #1
0
        /// <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);
        }
コード例 #2
0
 //查询
 public T GetById(int id)
 {
     return(curDal.GetById(id));
 }
コード例 #3
0
 public List <Brand> GetById(int id) => _brandDal.GetById(id);
コード例 #4
0
ファイル: ColorManager.cs プロジェクト: EmineAs/ReCapProject
 public List <Color> GetById(int id) => _colorDal.GetById(id);
コード例 #5
0
ファイル: CarManager.cs プロジェクト: EmineAs/ReCapProject
 public List <Car> GetById(int id) => _carDal.GetById(id);
コード例 #6
0
        public void Delete(long id)
        {
            var entity = _baseDal.GetById(id);

            _baseDal.Delete(entity);
        }