This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [master] | |
GO | |
/****** Object: Database [TrialsDB] | |
CREATE DATABASE [TrialsDB] | |
CONTAINMENT = NONE | |
ON PRIMARY | |
( NAME = N'TrialsDB', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\TrialsDB.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) | |
LOG ON | |
( NAME = N'TrialsDB_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\TrialsDB_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Configure-OutOfOffice-Message | |
{ | |
Add-Type -AssemblyName 'Microsoft.Office.Interop.Outlook' | |
$outlook = New-Object -ComObject outlook.application | |
$namespace = $outlook.GetNameSpace('MAPI') | |
$Calendar = [Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderCalendar | |
$folder = $namespace.getDefaultFolder($Calendar) | |
$Holidays = $folder.items | | |
Select-Object -Property Start, Categories | Where-Object Start -ge (Get-Date).AddDays(-1) | Where-Object Categories -eq 'Holiday' | |
Foreach($holiday in $Holidays) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$appName = "appname" | |
$apiName = "apiname" | |
$apiUri = "https://<tenantname>.onmicrosoft.com/api.access" | |
$secretStartDate = Get-Date | |
$secretEndDate = $secretStartDate.AddYears(10) | |
$myAdApp = New-AzureADApplication -DisplayName $appName -Oauth2AllowImplicitFlow $true -AvailableToOtherTenants $true | |
$myAdApi = New-AzureADApplication -DisplayName $apiName -AvailableToOtherTenants $true -KnownClientApplications $myAdApp.AppId -IdentifierUris $apiUri | |
$secret = New-AzureADApplicationPasswordCredential -ObjectId $myAdApi.ObjectId -CustomKeyIdentifier "GraphClientSecret" -StartDate $secretStartDate -EndDate $secretEndDate | |
$secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$appName = "appname" | |
$appHomePage = "companyhomepage" | |
$secretStartDate = Get-Date | |
$secretEndDate = $secretStartDate.AddYears(10) | |
$myAdApp = New-AzureADApplication -DisplayName $appName -HomePage $appHomePage -Oauth2AllowImplicitFlow $true -AvailableToOtherTenants $true | |
$secret = New-AzureADApplicationPasswordCredential -ObjectId $myAdApp.ObjectId -CustomKeyIdentifier "GraphClientSecret" -StartDate $secretStartDate -EndDate $secretEndDate | |
$secret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$appName = "appname" | |
$appUri = "appuri" | |
$appHomePage = "homepageuri" | |
$myAdApp = New-AzureADApplication -DisplayName $appName -Oauth2AllowImplicitFlow $true -AvailableToOtherTenants $true -IdentifierUris $appUri -HomePage $appHomePage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Graph; | |
using Microsoft.Graph.Auth; | |
using Microsoft.Identity.Client; | |
namespace < YOURNAMESPACE > { | |
public interface IGraphAuthService { | |
GraphServiceClient GetGraphServiceClient(Guid tenantId); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using Microsoft.Graph; | |
namespace < YOURNAMESPACE > { | |
public interface IGrapFacade { | |
Task < IGraphServiceUsersCollectionPage > GetUsersUsingGraph(Guid tenantId); | |
} | |
public class GraphFacade: IGrapFacade { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task < IEnumerable < UserDto >> GetUserList(Guid selectedTenant) { | |
_logger.LogInformation($ "The method {nameof(GetUserList)} is called"); | |
var appUsers = await _adminRepository.GetUsersWithRole(selectedTenant); | |
if (!appUsers.Any()) throw AdminException.FromCode(ErrorCode.NoUsersInDbSelectedTenant); | |
var users = await _graphFacade.GetUsersUsingGraph(selectedTenant); | |
if (!users.Any()) throw AdminException.FromCode(ErrorCode.NoUsersInAdSelectedTenant); | |
var combinedList = appUsers.Join(users, app = >app.UserId, graph =>new Guid(graph.Id), (app, graph) = >new UserDto { | |
DisplayName = graph.DisplayName, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet("getusers")] | |
public async Task<IActionResult> GetUsers() | |
{ | |
try | |
{ | |
_logger.LogInformation($"The method {nameof(GetUsers)} is called"); | |
var users = await _adminService.GetUserList(HttpContext.GetSelectedTenantId()); | |
if (!users.Any()) | |
{ | |
_logger.LogCritical($"The method {nameof(GetUsers)} returned no users"); |