Skip to content

Commit

Permalink
handle differently ldap attributes that do not support wildcard
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvand committed Feb 8, 2024
1 parent 954a78e commit 4a67b76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,17 +388,6 @@ internal void Add(ClaimTypeConfig item, bool strictChecks)
}
}
}

// Enforce some settings for specific LDAP attributes
if (String.Equals(item.DirectoryObjectAttribute, "objectSid", StringComparison.InvariantCultureIgnoreCase))
{
item.DirectoryObjectAttributeSupportsWildcard = false; // For objectSid, no wildcard possible
}
else if (String.Equals(item.DirectoryObjectAttribute, "primaryGroupID", StringComparison.InvariantCultureIgnoreCase))
{
item.DirectoryObjectAttributeSupportsWildcard = false; // For primaryGroupID, no wildcard possible
}

innerCol.Add(item);
}

Expand Down
12 changes: 11 additions & 1 deletion Yvand.LDAPCPSE/Yvand.LdapClaimsProvider/LdapEntityProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,18 @@ protected string BuildFilter(OperationContext currentContext)

protected string AddLdapAttributeToFilter(OperationContext currentContext, string input, ClaimTypeConfig attributeConfig)
{
string inputFormatted;
// Prevent use of wildcard for LDAP attributes which do not support it
if (String.Equals(attributeConfig.DirectoryObjectAttribute, "objectSid", StringComparison.InvariantCultureIgnoreCase))
{
attributeConfig.DirectoryObjectAttributeSupportsWildcard = false; // For objectSid, no wildcard possible
}
else if (String.Equals(attributeConfig.DirectoryObjectAttribute, "primaryGroupID", StringComparison.InvariantCultureIgnoreCase))
{
attributeConfig.DirectoryObjectAttributeSupportsWildcard = false; // For primaryGroupID, no wildcard possible
}

// Test if wildcard(s) should be added to the input
string inputFormatted;
if (currentContext.ExactSearch || !attributeConfig.DirectoryObjectAttributeSupportsWildcard)
{
inputFormatted = input;
Expand Down

0 comments on commit 4a67b76

Please sign in to comment.