.net - Updating a Password in RackSpace using C# -
i'm trying change password of main account , sub user in rackspacecloud using c# keep running usernotauthorized exception. weird because can else without error, reset api keys, list users , userid's(etc.). sample code
net.openstack.core.domain.cloudidentity cloudidentity = new cloudidentity()//admin credits { username = "me", apikey = "blahblahblah", }; cloudidentityprovider cloudidentityprovider = new cloudidentityprovider(cloudidentity); cloudidentityprovider.setuserpassword("correctuserid", "newp@ssw0rd", cloudidentity);
and error confusing because methods like,
cloudidentityprovider.listusers(cloudidentity) cloudidentityprovider.resetapikey("userid", cloudidentity);
work perfectly. or ideas appreciated. oh , btw addition info on exception same. "unable authenticate user , retrieve authorized service endpoints"
this bug. have opened issue 528 in meantime here workaround.
var cloudidentity = new cloudidentity { username = "{username}", apikey = "{api-key}" }; var cloudidentityprovider = new cloudidentityprovider(cloudidentity); var useraccess = cloudidentityprovider.authenticate(cloudidentity); var request = new httprequestmessage(httpmethod.post, string.format("https://identity.api.rackspacecloud.com/v2.0/users/{0}", useraccess.user.id)); request.headers.add("x-auth-token", useraccess.token.id); var requestbody = jobject.fromobject(new { user = new { username = useraccess.user.name } }); ((jobject)requestbody["user"]).add("os-ksadm:password", "{new-password}"); request.content = new stringcontent(requestbody.tostring(), encoding.utf8, "application/json"); using (var client = new httpclient()) { var response = client.sendasync(request).result; }
the cloud identity used must admin if need change user's password, otherwise non-admins may change own password.
Comments
Post a Comment