Esempio n. 1
0
        /// <summary>
        /// Add new AAD User with groups via Azure Runbook webhook call.
        ///
        /// Fire and forget action, the Azure Runbook will handle the creation and notification.
        /// The Runbook runs in Azure, has the rights to create users, sets some additional properties and sends an email with the temp password.
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <param name="requestByUser"></param>
        /// <param name="actionType"></param>
        /// <returns></returns>
        public async Task <string> AddAadUser(Models.User user, string requestByUser, string actionType)
        {
            var webhookToCall = _appSettings.WebHookUrlCreateUsersRunbook;

            var userInJson = JsonConvert.SerializeObject(user);
            var jobResult  = _webhookService.CallWebHook(userInJson, webhookToCall).Result;
            Job _job       = null;

            if (jobResult.Length != 0)
            {
                _job = await Task.Factory.StartNew(() => JsonConvert.DeserializeObject <Job>(jobResult));
            }

            string jobId = _job.JobIds[0];
            await _logTable.AddLogToTable(jobId, requestByUser, actionType, user.DisplayName);

            return(jobId);
        }