예제 #1
0
        public IActionResult GetByFilter(string filter)
        {
            if (String.IsNullOrEmpty(filter))
            {
                return(BadRequest());
            }
            try
            {
                ps.Commands.Clear();
                ps.AddCommand($@"Get-ADUser");
                ps.AddParameter("Filter", filter);
                ps.AddParameter("Properties", "*");
                var psos = ps.Invoke();
                if (psos.IsNullOrCountEqualsZero())
                {
                    return(NotFound());
                }

                var uis = psos.Select(c => ADUserFactory.Create(c));
                return(Ok(uis));
            }
            catch (Exception ex)
            {
                return(Ok(ex));
            }
        }
예제 #2
0
        public IActionResult Get(string name)
        {
            if (String.IsNullOrEmpty(name))
            {
                return(BadRequest());
            }
            ps.Commands.Clear();
            ps.AddScript($"Get-ADUser -Identity {name} -Properties *");
            var psos = ps.Invoke();

            if (psos.IsNullOrCountEqualsZero())
            {
                return(NotFound());
            }

            PSObject pso = psos.First();
            var      ui  = ADUserFactory.Create(pso);

            return(Ok(ui));
        }
예제 #3
0
        public IActionResult Get(string groupName)
        {
            if (String.IsNullOrEmpty(groupName))
            {
                return(BadRequest());
            }

            ps.Commands.Clear();
            ps.AddScript($@"Get-ADGroup -Identity ""{groupName}"" -Properties Members | Select-Object -ExpandProperty Members | Get-ADUser -Properties *");
            var psos = ps.Invoke();

            if (psos.IsNullOrCountEqualsZero())
            {
                return(NotFound());
            }

            var uis = psos.Select(c => ADUserFactory.Create(c));

            return(Ok(uis));
        }