the scim standard created simplify user management in cloud defining schema representing users , groups , rest api necessary crud operations.
it intended replace older spml protocol.
are there "mature" c# libraries out there?
most of stuff i've googled java or else doesn't seem active.
update:
in response comment:
these libraries of form:
user = new user; user.name = "name"; ... etc ... user.create;
in other words, hides underlying implementation using model user. way don't have worry details of actual protocol.
i've updated original answer provide better information.
a) library should (hopefully) you're looking for:
microsoft.systemforcrossdomainidentitymanagement
https://www.nuget.org/packages/microsoft.systemforcrossdomainidentitymanagement/
one of authors of project updated include v1 , v2 scim object support , absolutely correct links blog posts explains library's purpose.
(the author has added summary on nuget people find nuget library before reading blog post won't confused was).
here's example of deserialzing user based on request (to facebook), can create new user object , set it's properties etc. before post or put'ing system.
public static async task getuser() { var oauthtoken = "123456789foo"; var baseurl = "https://www.facebook.com/company/1234567890/scim/"; var username = "foo@bar.com"; using (var client = new httpclient()) { // set client , configure things oauthtoken need go on each request client.baseaddress = new uri(baseurl); // spoof user-agent keep facebook happy client.defaultrequestheaders.add("user-agent", "mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, gecko) chrome/46.0.2490.86 safari/537.36"); client.defaultrequestheaders.accept.clear(); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json")); client.defaultrequestheaders.authorization = new authenticationheadervalue("bearer", oauthtoken); try { var response = await client.getasync($"users?filter=username%20eq%20%22{username}%22"); response.ensuresuccessstatuscode(); var json = await response.content.readasstringasync(); // part using nuget library referenced var jsondictionary = new javascriptserializer().deserialize<dictionary<string, object>>(json); var queryresponse = new queryresponsejsondeserializingfactory<core1enterpriseuser>().create(jsondictionary); var user = queryresponse.resources.first(); } catch (exception ex) { // todo: handle exception } } }
i ran issue using newtonsoft deserialzier rather ms one:
var jsondictionary = await task.factory.startnew(() => { return jsonconvert.deserializeobject<dictionary<string, object>>(json); });
returned dictionary<string, object>
factory couldn't make proper use of it.
you can use core2user
or core2enterpriseuser
classes if you're using v2 of scim spec.
furthermore library, believe can handle creation of requests if want (rather crafting them seem pretty straightforward anyway), here's snippet author of project (craig mcmurtry)
/* * sampleprovider() included in service library. * sampleresource property provides 2.0 enterprise user values * set according samples in 2.0 schema specification. */ var resource = new sampleprovider().sampleresource; // composepostrequest() extension method on resource class provided protocols library. request = resource.composepostrequest("http://localhost:9000");
i hope helps, massive amount of due craig mcmurtry @ microsoft has been helpful in trying me , running library - don't have hand craft own model classes.
Comments
Post a Comment