vSphere Credential Store Subroutine Reference
The ViCredStore package includes the following subroutines:
init
Initializes the credential store. Call this subroutine once, before any of the other credential store subroutines. The credential store is not created until your program calls add_password.
This subroutine accepts the location of the credential store file. If you do not provide a credential store filename VICredStore::init() looks in the default location.
Linux: $HOME/.vmware/credstore/vicredentials.xml
Windows: %APPDATA%\VMware\credstore\vicredentials.xml
If no credential store exists at the default location, the initialization process:
Checks that the credstore directory exists, and creates one if it does not.
Creates the vicredentials.xml file and parent directory.
If you provide a non-default credential store filename to VICredStore::init(), the credential store at that location is used. If there is no credential store at that location and the directory you specify exists, the initialization process creates the file. If the directory you specify does not exist, the initialization process fails.
Parameters
Returns
Returns 1 if initialization is successful; otherwise, returns 0.
get_password
Retrieves the password for a specified server and user name.
Parameters
Returns
Returns the password, or undef if no password is found.
add_password
Creates a credential store file if none exists and stores the password for a given server and user name.
If a password already exists for that server and user name, add_password overwrites that password.
Parameters
Returns
Returns 1 if a password for this server and user does not exists; otherwise, returns zero.
remove_password
Removes the password for a given server and user name. If no password exists, this method has no effect.
Parameters
Returns
Returns 1 if the password existed and was successfully removed; otherwise, returns zero.
clear_passwords
Removes all passwords.
Parameters
No parameters.
Returns
Returns nothing.
get_hosts
Returns a list of all servers that have entries in the credential store.
Parameters
No parameters.
Returns
Returns a list of all servers in the credential store.
get_usernames
For a given server, returns all user names that have an associated password stored in the credential store.
Parameters
server – Server for which all user names are listed.
Returns
Returns a list of all users belonging to the specified server.
close
Closes the credential store, and frees all resources associated with it. If you want to run additional credential store subroutines, you must run init again to reinitialize the credential store.
Call close only once for each credential store initialized by a call to init.
Parameters
No parameters.
Returns
Returns nothing.