Exemplo n.º 1
0
        public IHttpActionResult CreateUser([FromBody] CreateUserModel user)
        {
            var script = _powershellScriptLoader.LoadScript(PowershellScripts.O365CreateUser);

            _powerShellUtility.AttachOffice365Credentials(_powerShellManager);
            _powerShellManager.AttachParameters(user.MapPropertiesToOffice365Parameters());

            var office365UserId = _powerShellManager.ExecuteScriptAndReturnFirst <Guid>(script);

            return(Ok(office365UserId));
        }
Exemplo n.º 2
0
        public IHttpActionResult CreateGroups([FromBody] DistributionGroupModel model)
        {
            var script = _powershellScriptLoader.LoadScript(PowershellScripts.AddDistributionGroup);

            _powerShellUtility.AttachOffice365Credentials(_powerShellManager);
            _powerShellManager.AttachParameters(model.MapPropertiesToOffice365Parameters());

            _powerShellManager.ExecuteScript(script);

            return(Ok());
        }
        public IHttpActionResult IsDomainVerified([FromBody] Office365CustomerDomainModel model)
        {
            var script = _powershellScriptLoader.LoadScript(PowershellScripts.IsDomainVerified);

            _powerShellUtility.AttachOffice365Credentials(_powerShellManager);
            _powerShellManager.AttachParameters(model.MapPropertiesToOffice365Parameters());

            var verified = _powerShellManager.ExecuteScriptAndReturnFirst <bool>(script);

            return(Ok(verified));
        }
Exemplo n.º 4
0
        public IHttpActionResult GetCustomerIdByDomain([FromBody] Office365CustomerDomainModel model)
        {
            var script = _powershellScriptLoader.LoadScript(PowershellScripts.GetCustomerIdByDomain);

            _powerShellUtility.AttachOffice365Credentials(_powerShellManager);
            _powerShellManager.AttachParameters(model.MapPropertiesToOffice365Parameters());

            var customerId = _powerShellManager.ExecuteScriptAndReturnFirst <string>(script);

            return(Ok(customerId));
        }
Exemplo n.º 5
0
        public IHttpActionResult Post([FromBody] HardDeleteUserModel user)
        {
            var script = _powershellScriptLoader.LoadScript(PowershellScripts.HardDeleteUser);

            _powerShellUtility.AttachOffice365Credentials(_powerShellManager);
            _powerShellManager.AttachParameters(user.MapPropertiesToOffice365Parameters());

            _powerShellManager.ExecuteScript(script);

            return(Ok(true));
        }
Exemplo n.º 6
0
        public IHttpActionResult Post([FromBody] Office365CustomerDomainModel model)
        {
            this.Log().Info("=> RemoveCustomerDomainController");

            var script = _powershellScriptLoader.LoadScript(PowershellScripts.RemoveCustomerDomain);

            _powerShellUtility.AttachOffice365Credentials(_powerShellManager);
            _powerShellManager.AttachParameters(model.MapPropertiesToOffice365Parameters());

            this.Log().Info("Start executing script!");
            _powerShellManager.ExecuteScript(script);

            return(Ok(true));
        }
        public IHttpActionResult Post([FromBody] SetUserImmutableIdModel user)
        {
            this.Log().Info("=> SetUserImmutableIdController");

            var script = _powershellScriptLoader.LoadScript(PowershellScripts.SetUserImmutableId);

            _powerShellUtility.AttachOffice365Credentials(_powerShellManager);
            _powerShellManager.AttachParameters(user.MapPropertiesToOffice365Parameters());

            this.Log().Info("Start executing script!");
            _powerShellManager.ExecuteScript(script);

            return(Ok(true));
        }
Exemplo n.º 8
0
        public IHttpActionResult Post([FromBody] Office365CustomerDomainModel model)
        {
            this.Log().Info("=> GetDomainTxtRecordController");

            var script = _powershellScriptLoader.LoadScript(PowershellScripts.GetDomainTxtRecord);

            _powerShellUtility.AttachOffice365Credentials(_powerShellManager);
            _powerShellManager.AttachParameters(model.MapPropertiesToOffice365Parameters());

            this.Log().Info("Start executing script!");
            var txtRecord = _powerShellManager.ExecuteScriptAndReturnFirst <string>(script);

            this.Log().Info($"TXT Record: {txtRecord}");

            return(Ok(txtRecord));
        }
        public IHttpActionResult GetMatchingData([FromBody] Office365CustomerDomainModel model)
        {
            var script = _powershellScriptLoader.LoadScript(PowershellScripts.GetTransitionMatchingData);

            _powerShellUtility.AttachOffice365Credentials(_powerShellManager);
            _powerShellUtility.AttachSqlHostAndCredentials(_powerShellManager);
            _powerShellManager.AttachParameters(model.MapPropertiesToOffice365Parameters());

            var list = new List <TransitionMatchingDataModel>();

            try
            {
                var result = _powerShellManager.ExecuteScriptAndReturnFirst <string>(script);

                if (result == null)
                {
                    return(Ok(list));
                }

                try
                {
                    return(Ok(JsonConvert.DeserializeObject <List <TransitionMatchingDataModel> >(result)));
                }
                catch (Exception)
                {
                    list.Add(JsonConvert.DeserializeObject <TransitionMatchingDataModel>(result));

                    return(Ok(list));
                }
            }
            catch (Exception ex)
            {
                this.Log().Error($"Error GetMatchingData: Office 365 CustomerId: {model.Office365CustomerId}, Domain: {model.Domain}", ex);

                return(Ok(list));
            }
        }
Exemplo n.º 10
0
        public IHttpActionResult GetAllGroups([FromBody] GroupsModel model)
        {
            var script = _powershellScriptLoader.LoadScript(PowershellScripts.GetGroupsListAllTypes);

            _powerShellUtility.AttachOffice365Credentials(_powerShellManager);
            _powerShellManager.AttachParameters(model.MapPropertiesToOffice365Parameters());

            var list = new List <GroupsListModel>()
            {
            };

            try
            {
                var result = _powerShellManager.ExecuteScript <string>(script);
                if (result == null)
                {
                    return(Ok(list));
                }

                try
                {
                    return(Ok(result));
                    //return Ok(JsonConvert.DeserializeObject<List<GroupsListModel>>(result));
                }
                catch (Exception)
                {
                    // list.Add(JsonConvert.DeserializeObject<GroupsListModel>(result));

                    return(Ok(list));
                }
            }
            catch (Exception ex)
            {
                this.Log().Error($"Error GetGroups: Office 365 CustomerId: {model.Office365CustomerId}", ex);

                return(Ok(list));
            }
            //var removedEmptyRoles = roles.Where(r => r.Length > 0);
        }