static async Task Main(string[] args) { Console.WriteLine("Microsoft Graph Test App started..."); var userId = new Guid("6061cc39-844c-4450-842e-171de08e9817"); AzureAdGraphSettings azureAdGraphSettings = new AzureAdGraphSettings(); IGraphApiService graphApiService = new GraphApiService(azureAdGraphSettings); graphApiService.Initialize(true); //Console.WriteLine("Getting users which did not accepted consents..."); //IDatabaseService databaseService = new DatabaseService(); //var usersWhichNotAcceptedConsents = databaseService.GetUsersWithUnAcceptedConsents(); //Console.WriteLine("\nGot users which did not accepted consents..."); //Console.WriteLine("================================================="); //Console.WriteLine("Getting user login information from the recent days..."); //DateTime fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 6); //var loginData = await graphApiService.GetLatestUserLoginData(); //var distinctLoginData = loginData.value.Select(x => x.userId).Distinct(); //foreach (var loginDataValue in loginData.value) //{ // Console.WriteLine($"Login data: {loginDataValue.createdDateTime} for user {loginDataValue.userId} {loginDataValue.userDisplayName} with provider: {loginDataValue.authenticationMethodsUsed.FirstOrDefault()}"); //} //Console.WriteLine("Getting user login information from the recent days..."); //var usersToDelete = distinctLoginData.Where(p => !usersWhichNotAcceptedConsents.Any(p2 => p2.UserId.ToString() == p)).ToList(); //Console.WriteLine("Users which should be deleted:"); //usersToDelete.ForEach(u => Console.WriteLine("User ID to delete: " + u)); Console.WriteLine("================================================="); //var users = await graphApiService.GetAllRegisteredUsers(); var auditLogs = await graphApiService.GetAuditLogsForUsers(); foreach (var log in auditLogs.value) { DateTime convertedDate = DateTime.SpecifyKind( DateTime.Parse(log.activityDateTime.ToString()), DateTimeKind.Utc); DateTime dt = convertedDate.ToLocalTime(); Console.WriteLine($"Found logins for: with date and time: {dt}"); } Console.ReadKey(); }
public static void ConfigureAppSettings(this IServiceCollection services, IConfiguration configuration) { var azureAdGraphConfiguration = new AzureAdGraphSettings() { AzureAdB2CTenant = configuration["AzureAdGraph:AzureAdB2CTenant"], ClientId = configuration["AzureAdGraph:ClientId"], ClientSecret = configuration["AzureAdGraph:ClientSecret"], PolicyName = configuration["AzureAdGraph:PolicyName"], ApiUrl = configuration["AzureAdGraph:ApiUrl"], ApiVersion = configuration["AzureAdGraph:ApiVersion"], ExtensionsAppClientId = configuration["AzureAdGraph:ExtensionsAppClientId"] }; services.AddSingleton(azureAdGraphConfiguration); var azureAdB2CSettings = new AzureAdB2CSettings() { ClientId = configuration["AzureAdB2C:ClientId"], Tenant = configuration["AzureAdB2C:Tenant"], Policy = configuration["AzureAdB2C:Policy"] }; services.AddSingleton(azureAdB2CSettings); var microsoftGraphSettings = new MicrosoftGraphSettings() { AzureAdB2CTenant = configuration["MicrosoftGraph:AzureAdB2CTenant"], ClientId = configuration["MicrosoftGraph:ClientId"], ClientSecret = configuration["MicrosoftGraph:ClientSecret"], ApiUrl = configuration["MicrosoftGraph:ApiUrl"], ApiVersion = configuration["MicrosoftGraph:ApiVersion"] }; services.AddSingleton(microsoftGraphSettings); var cosmosDbSettings = new CosmosDbSettings() { Account = configuration["CosmosDb:Account"], Key = configuration["CosmosDb:Key"], DatabaseName = configuration["CosmosDb:DatabaseName"], TutorLearningProfilesContainerName = configuration["CosmosDb:TutorLearningProfilesContainerName"], ChatMessagesContainerName = configuration["CosmosDb:ChatMessagesContainerName"] }; services.AddSingleton(cosmosDbSettings); var notificationHubSettings = new NotificationHubSettings() { HubName = configuration["NotificationHub:HubName"], HubDefaultFullSharedAccessSignature = configuration["NotificationHub:HubDefaultFullSharedAccessSignature"] }; services.AddSingleton(notificationHubSettings); }
public AdB2cGraphClientUserPropertiesProvider(HttpClient httpClient, IAzureAdGraphAuthenticationProvider azureAdGraphAuthenticationProvider, IMicrosoftGraphAuthenticationProvider microsoftGraphAuthenticationProvider, AzureAdGraphSettings azureAdGraphSettings, MicrosoftGraphSettings microsoftGraphSettings) { _httpClient = httpClient; _azureAdGraphAuthenticationProvider = azureAdGraphAuthenticationProvider; _microsoftGraphAuthenticationProvider = microsoftGraphAuthenticationProvider; _azureAdGraphSettings = azureAdGraphSettings; _microsoftGraphSettings = microsoftGraphSettings; }
public AzureAdGraphAuthenticationProvider(AzureAdGraphSettings settings) { _settings = settings; }
public GraphApiService(AzureAdGraphSettings azureAdGraphSettings) { _azureAdGraphSettings = azureAdGraphSettings; }
public GraphApiConnector(IAuthenticationProvider authenticationProvider, AzureAdGraphSettings settings) { _authenticationProvider = authenticationProvider; _settings = settings; }