protected internal override bool TryGetSpecialSourceClaim(ClaimsPrincipal principal, string source, out IClaimBuilder claim)
        {
            if (principal == null)
            {
                throw new ArgumentNullException(nameof(principal));
            }

            if (base.TryGetSpecialSourceClaim(principal, source, out claim))
            {
                return(true);
            }

            // ReSharper disable InvertIf
            if (!string.IsNullOrWhiteSpace(source) && source.StartsWith(this.ActiveDirectorySourcePrefix, StringComparison.OrdinalIgnoreCase))
            {
                var attributes = new List <string>();

                if (!this.ActiveDirectoryIntegration)
                {
                    this.Logger.LogWarningIfEnabled($"Could not get special source-claim for source {this.ValueAsFormatArgument(source)}. Active-Directory integration is not enabled.");
                }
                else if (source.Equals(this.ActiveDirectoryEmailSource, StringComparison.OrdinalIgnoreCase))
                {
                    attributes.Add(this.ActiveDirectoryEmailAttributeName);
                }
                else if (source.Equals(this.ActiveDirectoryUserPrincipalNameSource, StringComparison.OrdinalIgnoreCase))
                {
                    attributes.Add(this.ActiveDirectoryUserPrincipalNameAttributeName);
                }
                else
                {
                    this.Logger.LogDebugIfEnabled($"Could not get special source-claim for source {this.ValueAsFormatArgument(source)}.");
                }

                if (attributes.Any())
                {
                    try
                    {
                        var result = this.ActiveDirectory.GetAttributesAsync(attributes, this.IdentifierKind, principal).Result;

                        if (result.Any())
                        {
                            claim = new ClaimBuilder
                            {
                                Type  = source,
                                Value = result.First().Value
                            };

                            claim.Issuer = claim.OriginalIssuer = this.ActiveDirectoryClaimIssuer;
                        }
                        else
                        {
                            this.Logger.LogWarningIfEnabled($"Could not get special source-claim for source {this.ValueAsFormatArgument(source)}. No items were returned for attributes \"{string.Join(", ", attributes)}\".");
                        }
                    }
                    catch (Exception exception)
                    {
                        this.Logger.LogErrorIfEnabled(exception, $"Could not get special source-claim for source {this.ValueAsFormatArgument(source)}.");
                    }
                }

                return(true);
            }
            // ReSharper restore InvertIf

            return(false);
        }
		protected internal virtual bool TryGetSpecialSourceClaim(ClaimsPrincipal principal, string source, out IClaimBuilder claim)
		{
			if(principal == null)
				throw new ArgumentNullException(nameof(principal));

			claim = null;

			// ReSharper disable InvertIf
			if(!string.IsNullOrWhiteSpace(source) && source.StartsWith(this.PrincipalIdentitySourcePrefix, StringComparison.OrdinalIgnoreCase))
			{
				if(source.Equals(this.PrincipalIdentityAuthenticationTypeSource, StringComparison.OrdinalIgnoreCase))
				{
					claim = new ClaimBuilder
					{
						Type = source,
						Value = principal.Identity.AuthenticationType
					};

					var firstPrincipalClaim = principal.Claims?.FirstOrDefault();

					claim.Issuer = firstPrincipalClaim?.Issuer;
					claim.OriginalIssuer = firstPrincipalClaim?.OriginalIssuer;
				}
				else
				{
					this.Logger.LogDebugIfEnabled($"Could not get special source-claim for source {this.ValueAsFormatArgument(source)}.");
				}

				return true;
			}
			// ReSharper restore InvertIf

			return false;
		}