Autodesk Vault Programmer's Cookbook/Login/Log in to Vault



Establish Autodesk Vault connection.



Create WebServiceManager from Autodesk.Connectivity.WebServices.dll with credentials parameters.

#Connecting dll
Add-Type -Path "C:\Program Files (x86)\Autodesk\Autodesk Vault 2014 SDK\bin\Autodesk.Connectivity.WebServices.dll"
#Retreiving read-only credentials
$cred = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials ("localhost", "Vault", "Administrator", "", $true)
#Creating manager
$webSvc = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager ($cred)



WebServiceManager is your gates to the garden of Vaulty API. And IWebServiceCredentials is a key to this gates.
You can create this key in at least 16 different ways (A-P) of getting IWebServiceCredentials.

The ways of establishing connection with Autodesk Vault 2014 API

After connection you can get next information about connection:

Method Description
ReadOnly Gets if the connection is read only.
RequiresSignIn Gets the value telling if a sign in is required before a service can be used.
RequiresSignOut Gets the value telling if a sign out should be called when the service goes out of scope.
SecurityHeader Gets the security header.
ServerIdentities Gets the server identity.
SupportsSignIn Gets the value telling if the credentials can sign in.
SupportsSignOut Gets the value telling if the credentials can sign out.
UserName Gets the username.
VaultName Gets the vault name.

Connecting is quite simple operation, but its fundamental for any program that needs connect to Vault server. Here's algorithm, that describes logging with UserPasswordCredentials:
And here's "cmd edition", that handles errors and gives more verbose:

param ($help,$VServer,$VVault,$VUser,$VPass,$VOut)

$WebServicesPath2014="C:\Program Files (x86)\Autodesk\Autodesk Vault 2014 SDK\bin\Autodesk.Connectivity.WebServices.dll"

if ($help)
"Login Vault with read-only connection`n"
"  Login-VaultServer.ps1 -Vserver <server address> -VVault <vault name> -VUser <username> [-VPass <password>]`n"
"  -Vserver		Autodesk Vault server name. In any format: IP, DNS, IP:port, DNS:port."
"  -VVault		Vault name."
"  -VUser		Registered user name."
"  -VPass		Password."
"  powershell .\Export-FileCategories.ps1 -Vserver localhost -VVault Vault -VUser Administrator -VPass pass`n"
	if (!$VServer -or !$VVault -or !$VUser){"Invalid arguments. Use 'help' argument for more help"

	"Trying to find Vault 2014 dll"
	Add-Type -Path $WebServicesPath2014 #Vault 2014
	"No dlls were found. Edit script or contact author."

"Found - executing"
$cred = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials ($VServer,$VVault,$VUser,$VPass,$true)
$webSvc = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager ($cred)
Write-Output $webSvc
{"Login failed"

And the best way to login - is certainly by using dialogs fromVDF.

#Connect dll
Add-Type -Path "c:\Program Files (x86)\Autodesk\Autodesk Vault 2014 SDK\bin\Autodesk.DataManagement.Client.Framework.Vault.Forms.dll"
#Call login dialog and workflow, get credentials on successful login 

As a result, you'll get a login dialog with the information you entered last time.