public static Grouper CreateFromConfig(GrouperConfiguration config) { Grouper grouper = new Grouper(config.ChangeRatioLowerLimit); if (config.AzureAdRole != null && config.AzureAdRole.Length > 0) { AzureAd az = new AzureAd(config); if (config.AzureAdHasRole(GrouperConfiguration.Role.GroupStore)) { grouper.AddGroupStore(az); } if (config.ExchangeHasRole(GrouperConfiguration.Role.MemberSource)) { grouper.AddMemberSource(az); } if (config.AzureAdHasRole(GrouperConfiguration.Role.GroupOwnerSource)) { grouper.AddGroupOwnerSource(az); } } if (config.ExchangeRole != null && config.ExchangeRole.Length > 0) { Exo exo = new Exo(config); if (config.ExchangeHasRole(GrouperConfiguration.Role.GroupStore)) { grouper.AddGroupStore(exo); } if (config.ExchangeHasRole(GrouperConfiguration.Role.MemberSource)) { grouper.AddMemberSource(exo); } } if (config.OnPremAdHasRole(GrouperConfiguration.Role.GroupStore)) { OnPremAd onPremAd = new OnPremAd(config); if (config.OnPremAdHasRole(GrouperConfiguration.Role.GroupStore)) { grouper.AddGroupStore(onPremAd); } if (config.OnPremAdHasRole(GrouperConfiguration.Role.MemberSource)) { grouper.AddMemberSource(onPremAd); } } if (!string.IsNullOrEmpty(config.MemberDatabaseConnectionString)) { grouper.AddMemberSource(new MemberDb(config)); } if (!string.IsNullOrEmpty(config.LogDatabaseConnectionString)) { grouper.AddLogger(new LogDb(config)); } if (!string.IsNullOrEmpty(config.OpenEDatabaseConnectionString)) { grouper.AddGroupStore(new OpenE(config)); } return(grouper); }
public static async Task <string> GetTokenByCode(AzureAd azureAd) { var ctx = new AuthenticationContext("https://login.microsoftonline.com/common"); var resource = azureAd.Resource; var clientId = azureAd.ClientId; var deviceCodeResult = await ctx.AcquireDeviceCodeAsync(resource, clientId); Console.ResetColor(); Console.WriteLine("You need to sign in."); Console.WriteLine("Message: " + deviceCodeResult.Message); var authResult = await ctx.AcquireTokenByDeviceCodeAsync(deviceCodeResult); return(authResult.AccessToken); }
public static AzureAd GetAzureAdDto() { InitializeConfigRootIfNull(); if (_azureAd == null) { AzureAd azureAdInfo = new AzureAd(); _configRoot .GetSection("AzureAD") .Bind(azureAdInfo); _azureAd = azureAdInfo; } return(_azureAd); }
private static AuthenticationResult GetAuthenticationResult() { AzureAd azureAdInfo = ConfigHolder.GetAzureAdDto(); string aadInstance = azureAdInfo.AADInstance; string tenant = azureAdInfo.Tenant; string clientId = azureAdInfo.ClientId; string appKey = azureAdInfo.AppKey; string resourceId = azureAdInfo.ResourceId; string authority = string.Format(aadInstance, tenant); AuthenticationContext authContext = new AuthenticationContext(authority); ClientCredential clientCredential = new ClientCredential(clientId, appKey); AuthenticationResult authResult = null; int retryCount = 0; bool retry; do { retry = false; try { authResult = authContext.AcquireTokenAsync(resourceId, clientCredential).Result; return(authResult); } catch (AdalException ex) { if (ex.ErrorCode == "temporarily_unavailable") { retry = true; retryCount++; Thread.Sleep(3000); } } } while (retry && retryCount < 3); if (authResult == null) { throw new AuthenticationException("Could not authenticate with the OAUTH2 claims provider after several attempts"); } return(authResult); }
public AccountService(IOptions <AzureAd> adSettings, IQueueService queueService) { _adSettings = adSettings.Value; _queueService = queueService; }
public ValuesController(IOptions <AzureAd> settings) { AzureAdSettings = settings.Value; }
public ValuesController(IOptions <AzureAd> azureAdSettings) { this.azureAd = azureAdSettings.Value; }
public static void SyncUsers(AzureAd AzureAdSettings) { try { userAdModelClasses = new List <UserAdModelClass>(); UserAdModelClass someUserModelClass = new UserAdModelClass(); Task <IEnumerable <UserAdModelClass> > usersEnum = GetUsers(); Task continuation = usersEnum.ContinueWith(x => someUserModelClass = LoadUserAdData(x.Result)); continuation.Wait(); List <DAL.NueUserProfile> nueUserProfilesMaster = new DataAccess(AzureAdSettings).getAllUserProfilesDinamic(); List <UserAdModelClass> toBeAdded = new List <UserAdModelClass>(); List <UserAdModelClass> toBeRemoved = new List <UserAdModelClass>(); if (userAdModelClasses.Count > 0) { var abc = userAdModelClasses.Where(x => x.email == "*****@*****.**"); foreach (var item in userAdModelClasses) { try { if (!IsEmailValid(item.email)) { } if (nueUserProfilesMaster.Where(x => x.Email.ToLower() == item.email.ToLower()).Count() <= 0) { toBeAdded.Add(item); } } catch (Exception e1) { } } //string emailToRE = ""; foreach (var item in nueUserProfilesMaster) { try { if (!IsEmailValid(item.Email)) { } if (userAdModelClasses.Where(x => x.email.ToLower() == item.Email.ToLower()).Count() <= 0) { toBeRemoved.Add(new UserAdModelClass(item.Email, item.FullName)); //emailToRE += item.Email+", "; } } catch (Exception e1) { } } new DataAccess(AzureAdSettings).sincUsersAd(toBeAdded, toBeRemoved); } } catch (Exception e1) { } }
public AccountController(IOptions <AzureAd> options) { this.azureAd = options.Value; }
public Client(IOptions <AzureAd> azureAd, IMsalAuthenticator msalAuthenticator) { _azureAd = azureAd.Value; _auth = msalAuthenticator; }
public ValuesController(IOptions <AzureAd> settings, IHostingEnvironment hostingEnvironment) { AzureAdSettings = settings.Value; _hostingEnvironment = hostingEnvironment; }