private IEnumerable <Auth0.Connection> GetConnections(string connectionType) { IEnumerable <Auth0.Connection> connections = null; try { if (string.IsNullOrEmpty(connectionType)) { // All connections connections = this.auth0Client.GetConnections(); } else if (connectionType.Equals(EnterpriseHierarchyNode, StringComparison.OrdinalIgnoreCase)) { connections = this.auth0Client.GetEnterpriseConnections(); } else if (connectionType.Equals(SocialHierarchyNode, StringComparison.OrdinalIgnoreCase)) { connections = this.auth0Client.GetSocialConnections(); } Auth0LoggingService.Write("GetConnections: Total connections {0}", connections != null ? connections.Count() : 0); } catch (Exception ex) { Auth0LoggingService.WriteError(ex.ToString()); } return(connections != null ? connections : new List <Auth0.Connection>()); }
protected void InitializeAuth0Client() { this.auth0Config = this.configurationRepository.GetConfiguration(); if (!this.auth0Config.IsValid) { return; } try { var clientsIds = this.auth0Config.ClientId.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); var clientsSecrets = this.auth0Config.ClientSecret.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); var clientIdIndex = Array.IndexOf(clientsIds, Utils.GetClaimsValue(ClientIdClaimsType)); // if clientID was not found, use the first one configured on central admin if (clientIdIndex == -1) { clientIdIndex = 0; } this.auth0Client = new Auth0.Client( clientsIds[clientIdIndex], clientsSecrets[clientIdIndex], this.auth0Config.Domain); } catch (Exception ex) { Auth0LoggingService.WriteError(ex.ToString()); } this.alwaysResolveValue = true; //this.auth0Config.AlwaysResolveUserInput; this.pickerEntityGroupName = this.auth0Config.PickerEntityGroupName; }
protected virtual ICollection <ConsolidatedResult> ResolveInputBulk(string input, string selectedNode) { Auth0LoggingService.Write("ResolveInputBulk: input={0}, selectedNode={1}", input, selectedNode); if (string.IsNullOrEmpty(input)) { return(null); } if (this.auth0Client == null) { Auth0LoggingService.WriteError("Auth0 client was not initialized."); return(null); } IEnumerable <Auth0.User> users = null; var consolidatedResults = new Collection <ConsolidatedResult>(); try { Auth0LoggingService.Write("ResolveInputBulk: Searching for social and enterprise users."); var socialUsers = this.auth0Client.GetSocialUsers(input); var enterpriseUsers = this.auth0Client.GetEnterpriseUsers(input); // Distinct by user.Email users = socialUsers.Union(enterpriseUsers).DistinctBy(u => u.Email); // Log results. Auth0LoggingService.Write("ResolveInputBulk: Found {0}.", users != null ? users.Count() : 0); } catch (Exception ex) { Auth0LoggingService.WriteError(ex.ToString()); } if (users != null) { foreach (var user in users) { var claimAttribute = new ClaimAttribute { ClaimEntityType = SPClaimEntityTypes.User, PeoplePickerAttributeDisplayName = UsersNode, PeoplePickerAttributeHierarchyNodeId = UsersNode }; consolidatedResults.Add(new ConsolidatedResult { Attribute = claimAttribute, Auth0User = user, PickerEntity = this.GetPickerEntity(user, SPClaimEntityTypes.User) }); } } return(consolidatedResults); }
/// <summary> /// Get the first TrustedLoginProvider associated with current claim provider /// </summary> /// <param name="ProviderInternalName"></param> /// <returns></returns> public static SPTrustedLoginProvider GetSPTrustAssociatedWithCP(string providerInternalName) { var providers = SPSecurityTokenServiceManager.Local.TrustedLoginProviders.Where(p => p.ClaimProviderName == providerInternalName); if (providers != null && providers.Count() > 0) { if (providers.Count() == 1) { return(providers.First()); } else { Auth0LoggingService.WriteError("Claim provider '{0}' is associated to several TrustedLoginProvider, which is not supported because there is no way to determine what TrustedLoginProvider is currently calling the claim provider during search and resolution.", providerInternalName); } } Auth0LoggingService.WriteError("Claim provider '{0}' is not associated with any SPTrustedLoginProvider, and it cannot create permissions for a trust if it is not associated to it.\r\nUse PowerShell cmdlet Get-SPTrustedIdentityTokenIssuer to create association", providerInternalName); return(null); }