Skip to content

Commit 0ef0126

Browse files
dev-experienceSefriol
authored andcommitted
Add filters for id and displayName
1 parent 0f6a409 commit 0ef0126

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Microsoft.SCIM.WebHostSample/Provider/InMemoryUserProvider.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,19 @@ public override Task<Resource[]> QueryAsync(IQueryParameters parameters, string
129129
throw new ArgumentException(SystemForCrossDomainIdentityManagementServiceResources.ExceptionInvalidParameters);
130130
}
131131

132+
// ID filter
133+
else if (andFilter.AttributePath.Equals(AttributeNames.Identifier, StringComparison.OrdinalIgnoreCase))
134+
{
135+
if (andFilter.FilterOperator != ComparisonOperator.Equals)
136+
{
137+
throw new NotSupportedException(
138+
string.Format(SystemForCrossDomainIdentityManagementServiceResources.ExceptionFilterOperatorNotSupportedTemplate, andFilter.FilterOperator));
139+
}
140+
141+
var id = andFilter.ComparisonValue;
142+
predicateAnd = predicateAnd.And(p => string.Equals(p.Identifier, id, StringComparison.OrdinalIgnoreCase));
143+
}
144+
132145
// UserName filter
133146
else if (andFilter.AttributePath.Equals(AttributeNames.UserName, StringComparison.OrdinalIgnoreCase))
134147
{
@@ -174,6 +187,19 @@ public override Task<Resource[]> QueryAsync(IQueryParameters parameters, string
174187
predicateAnd = predicateAnd.And(p => p.Active == active);
175188
}
176189

190+
// DisplayName Filter
191+
else if (andFilter.AttributePath.Equals(AttributeNames.DisplayName, StringComparison.OrdinalIgnoreCase))
192+
{
193+
if (andFilter.FilterOperator != ComparisonOperator.Equals)
194+
{
195+
throw new NotSupportedException(
196+
string.Format(SystemForCrossDomainIdentityManagementServiceResources.ExceptionFilterOperatorNotSupportedTemplate, andFilter.FilterOperator));
197+
}
198+
199+
var displayName = andFilter.ComparisonValue;
200+
predicateAnd = predicateAnd.And(p => p.DisplayName == displayName);
201+
}
202+
177203
//LastModified filter
178204
else if (andFilter.AttributePath.Equals(
179205
$"{AttributeNames.Metadata}.{AttributeNames.LastModified}",

0 commit comments

Comments
 (0)