PowerShell - Authenticating using Windows credentials

PowerShell - Authenticating using Windows credentials

donalmcnamee
Advocate Advocate
1,588 Views
3 Replies
Message 1 of 4

PowerShell - Authenticating using Windows credentials

donalmcnamee
Advocate
Advocate

Has anyone any experience of connecting to Vault via PowerShell, but using Windows credentials?

For example, the following code throws an error "New-Object : Exception calling ".ctor" with "1" argument(s): "311""

 

Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
[System.Reflection.Assembly]::LoadFrom('C:\Program Files (x86)\Autodesk\Autodesk Vault 2019 SDK\bin\x64\Autodesk.Connectivity.WebServices.dll')
$serverID = New-Object Autodesk.Connectivity.WebServices.ServerIdentities
   $serverID.DataServer = "MYSERVER"
   $serverID.FileServer = "MYSERVER"
  $VaultName = "MYVAULT"

  $cred = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials ($serverID, $VaultName, $true)
  $vault = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager($cred)

 

The only thing I found online was this https://github.com/miwaniza/Autodesk_Vault_Programmers_Cookbook/blob/master/2.%20Login/1.3.%20Window...

But it would seem to suggest that I don't need to pass my username and password to UserPasswordCredentials when authenticating using Active Directory.

 

Using simple username/password authentication as per this (https://forums.autodesk.com/t5/vault-customization/here-is-a-working-windows-login-to-vault-but-how-...) does not work either.

 

Any ideas?

0 Likes
1,589 Views
3 Replies
Replies (3)
Message 2 of 4

ihayesjr
Community Manager
Community Manager

See if the Autodesk University class helps.

https://www.autodesk.com/autodesk-university/class/Feel-Power-Between-Vault-and-PowerShell-2019




Irvin Hayes Jr
Principal Product Manager
Autodesk, Inc.

Vault - Under the Hood Blog
0 Likes
Message 3 of 4

donalmcnamee
Advocate
Advocate

Hi @ihayesjr 

 

I seen that article alright, but it didn't help much. From what I can make out, the method used to connect to the Vault in the article uses told Connectivity.WebServicesTools mechanism and I don't see how to pass Windows credentials using that mechanism.

 

I changed my tact a little and I'm now writing my program in C# as opposed to PowerShell. I can connect to the Vault in C# using the new Vault Concurrency ConnectionManager.

            VDF.Vault.Results.LogInResult results = VDF.Vault.Library.ConnectionManager.LogIn("myserver", "myvault", null, null, AuthenticationFlags.WindowsAuthentication, null);

 

I'm sure there's a way to achieve the same in PowerShell, but I just can't see it at the moment.

0 Likes
Message 4 of 4

menno.jorna
Explorer
Explorer

Same issue here, cannot manage to login to vault with Windows Account and Powershell using Connectivity.WebServicesTools. Does anyone know how to do so?

0 Likes