You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alan Quillin edited this page Apr 25, 2014
·
6 revisions
Identity service (keystone)
Since all service endpoints use the identity service for authentication and authorization, we will start here.
User Authentication
Authenticate with username and password
//Required namespacesusingnet.openstack.Providers.Rackspace;usingnet.openstack.Core.Providers;usingnet.openstack.Core.Exceptions.Response;//Code snippettry{IIdentityProvideridentityProvider=newCloudIdentityProvider();varuserAccess=identityProvider.Authenticate(newRackspaceCloudIdentity{Username="MyUserName",Password="MyPassword"});}catch(ResponseExceptionex2){// do something}
Authenticate with username and API key
try{IIdentityProvideridentityProvider=newCloudIdentityProvider();varuserAccess=identityProvider.Authenticate(newRackspaceCloudIdentity{Username="MyUserName",APIKey="MyAPIKey"});}catch(ResponseExceptionex2){// do something}
By default, the US (default) cloud instance is used (This is the instance for all Cloud Regions EXCEPT LON. All future cloud instances will be in US (default) the cloud region). If you need to target the LON cloud instance, you only need to pass in the CloudInstance.UK
Authenticate at the LON cloud instance.
try{IIdentityProvideridentityProvider=newCloudIdentityProvider();varuserAccess=identityProvider.Authenticate(newRackspaceCloudIdentity{Username="MyUserName",Password="MyPassword",CloudInstance=CloudInstance.UK});}catch(ResponseExceptionex2){// do something}
User Details and Roles
retrieving details about a user is reserved for either admins, or the requesting user retrieving their own information. The examples below show a user retrieving their own if, but we will have an examples of what administrative accounts can do.
Basic user methods
Retrieve user details by username
try{IIdentityProvideridentityProvider=newCloudIdentityProvider();varidentity=newRackspaceCloudIdentity{Username="MyUserName",APIKey="MyPassword"};varuserDetails=identityProvider.GetUserByName(identity,"MyUserName");}catch(ResponseExceptionex2){// do something}
Retrieve user details by user id
try{IIdentityProvideridentityProvider=newCloudIdentityProvider();varidentity=newRackspaceCloudIdentity{Username="MyUserName",APIKey="MyPassword"};varuserDetails=identityProvider.GetUser(identity,"UserId");}catch(ResponseExceptionex2){// do something}
Administrative user methods
These methods are only available to user that exist in the identity:user-admin role. If the requesting user does not exist in this role, a exception will be thrown.
Add User
List all global Roles
try{IIdentityProvideridentityProvider=newCloudIdentityProvider();varidentity=newRackspaceCloudIdentity{Username="MyAdminUserName",APIKey="MyAdminPassword"};varuserDetails=identityProvider.ListRoles(identity)}catch(ResponseExceptionex2){// do something}