Getting Access to vCloud Director
The backup/restore software component must use system administrator privileges to connect to vCloud Director, so that it can access any Organization. The system administrator always logs into the System organization. When
Administrator@System
is used as the user name for the API, Administrator
is the login name and System
is the System Organization name.Using system administrator privileges to connect to vCloud Director also allows the backup/restore software to access additional information relating a vApp to the corresponding resources in vSphere. This is described in Inventory Access.
The following example shows how to log in using C# with the vCloud SDK for .NET. After logging in, the code shows how to access Organization data.
// vCloud Director login code sample using Administrator@System/<password> using com.vmware.vcloud.sdk; using com.vmware.vcloud.api.rest.schema; public static vCloudClient client = null; client = new vCloudClient(vCloudURL, com.vmware.vcloud.sdk.constants.Version.V1_5); client.Login(username, password); // Get references to all Organizations: Dictionary<string,ReferenceType> organizationsMap = client.GetOrgRefsByName(); // Get reference to a specific Organization: string orgName = "Org1"; ReferenceType orgRef = client.GetOrgRefByName(orgName); // Convert Organization reference to Organization object: Organization org = Organization.GetOrganizationByReference(client, orgRef);