Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Including the requested SelectProperties in the output of ListUsers #460

Merged
merged 1 commit into from
Sep 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/lib/PnP.Framework/Graph/UsersUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ public static Model.User GetUser(string accessToken, string userPrincipalName, s
AccountEnabled = u.AccountEnabled,
};

// If additional properties have been provided, ensure their output gets added to the AdditionalProperties dictonary of the output
if (selectProperties != null)
{
foreach (var selectProperty in selectProperties)
{
// Ensure the requested property has been returned in the response
var property = u.GetType().GetProperty(selectProperty);
if (property != null)
{
// Add the property to the AdditionalProperties dictionary
user.AdditionalProperties.Add(selectProperty, property.GetValue(u));
}
}
}

users.Add(user);
}
}
Expand Down