示例#1
0
        /// <summary>
        /// Returns AD User for passed in Login Id
        /// </summary>
        /// <param name="samAccountName"></param>
        /// <returns></returns>
        public ADUser SearchUserByLogin(string samAccountName)
        {
            try
            {
                var searcher = new RealPrincipalSearcher();
                ActiveDirectoryHelper helper = new ActiveDirectoryHelper(searcher);
                return(helper.SearchUserByLogin(samAccountName));
            }
            catch (Exception ex)
            {
                ///*log erorr locally */
                string    message = string.Format("Error in  SearchUserByLogin(string samAccountName:{0}); Detailed exception:{1}", samAccountName, ex.ToString());
                Exception custom  = new Exception(message);
                ExceptionManager.HandleException(custom);

                ServiceErrorFault fault = new ServiceErrorFault();
                fault.Operation   = "Directory Service";
                fault.ProblemType = "Error in SearchUserByLogin";

                var faultExp = new FaultException <ServiceErrorFault>(fault, ex.ToString());


                throw faultExp;
            }
        }
示例#2
0
        /// <summary>
        /// Returns List of AD Users, searched by first and last name,
        /// Supports wild card.
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <returns></returns>
        public List <ADUser> SearchUserByName(string firstName, string lastName)
        {
            try
            {
                var searcher = new RealPrincipalSearcher();
                ActiveDirectoryHelper helper = new ActiveDirectoryHelper(searcher);
                return(helper.SearchUserByName(firstName, lastName));
            }
            catch (Exception ex)
            {
                /*log erorr locally */
                string    message = string.Format("Error in  SearchUserByName(string firstName:{0}, string lastName{1}); Detailed exception:{2}", firstName, lastName, ex.ToString());
                Exception custom  = new Exception(message);
                ExceptionManager.HandleException(custom);

                ServiceErrorFault fault = new ServiceErrorFault();
                fault.Operation   = "Directory Service";
                fault.ProblemType = "Error in SearchUserByName";

                throw new FaultException <ServiceErrorFault>(fault);
            }
        }
示例#3
0
        /// <summary>
        /// Retrives all users in Group
        /// </summary>
        /// <param name="groupName"></param>
        /// <returns></returns>
        public List <ADUser> GetUsersInGroupMembership(string groupName)
        {
            try
            {
                var searcher = new RealPrincipalSearcher();
                ActiveDirectoryHelper helper = new ActiveDirectoryHelper(searcher);
                return(helper.GetUsersInGroupMembership(groupName));
            }
            catch (Exception ex)
            {
                /*log erorr locally */
                string    message = string.Format("Error in  GetUsersInGroupMembership(string groupName:{0} Detailed exception:{1}", groupName, ex.ToString());
                Exception custom  = new Exception(message);
                ExceptionManager.HandleException(custom);

                ServiceErrorFault fault = new ServiceErrorFault();
                fault.Operation   = "Directory Service";
                fault.ProblemType = "Error in GetUsersInGroupMembership";

                throw new FaultException <ServiceErrorFault>(fault);
            }
        }