Get Display Name of Current Vault User

Get Display Name of Current Vault User

pmartick
Advocate Advocate
230 Views
2 Replies
Message 1 of 3

Get Display Name of Current Vault User

pmartick
Advocate
Advocate

Inventor/Vault Pro 2025

 

This should be a fairly simple iLogic rule but there is a step I'm missing and I can't quite figure it out:

 

AddReference "Autodesk.Connectivity.WebServices.dll"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
Imports Autodesk.Connectivity.WebServices

Dim oAdmin As AdminService' is a Class Object but cannot create New instances from it?

'To verify UserId is not empty.
MessageBox.Show(CStr(iLogicVault.GetVaultConnection.UserID))

'The method to get User object via UserId from thee AdminService Class
Dim oInfo As User = oAdmin.GetUserByUserId(iLogicVault.GetVaultConnection.UserID)

'Show Display Name of current Vault Login.
MessageBox.Show(oInfo.Name)

 

I believe I have all the necessary dll references and imports but I cannot figure out what I need to do with the AdminService class object to access the method I need from it.

 

Thanks in advance.

0 Likes
Accepted solutions (1)
231 Views
2 Replies
Replies (2)
Message 2 of 3

Mike.Wohletz
Collaborator
Collaborator
Accepted solution

The AdminServices is going to require an elevated account to access this so you may need to get the password stored in a secure location for this to work. Replace the information noted and this will return the user name. 

AddReference "Autodesk.Connectivity.WebServices.dll"
AddReference "Autodesk.DataManagement.Client.Framework.Vault.dll"
Imports Autodesk.Connectivity.WebServices
Public Sub Main()
	
Dim m_Conn As Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.Connection = VaultLogin
If Not m_Conn Is Nothing Then
Dim user As User = m_Conn.WebServiceManager.AdminService.GetUserByUserId(iLogicVault.GetVaultConnection.UserID)
MsgBox(user.name)

End If

End Sub

Public Function VaultLogin() As Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.Connection
        Dim connection As Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.Connection = Nothing

        ' get the Vault login information
        Dim sVaultServer As String = "HTTPS://{YourVaultServer}"
        Dim sVaultName As String = "Vault" ' Your vault name
        Dim sVaultUsername As String = "Administrator" 'Your Vault admin
        Dim sVaultPassword As String = "" 'Your Vault Admin Password
        Dim results As Autodesk.DataManagement.Client.Framework.Vault.Results.LogInResult = Autodesk.DataManagement.Client.Framework.Vault.Library.ConnectionManager.LogIn(sVaultServer, sVaultName, sVaultUsername, sVaultPassword, Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)
        ' check to see if that was successful
        If results.Success Then
            connection = results.Connection
        Else
           
            Dim sLoginErrors As String = String.Join(Environment.NewLine, results.ErrorMessages.[Select](Function(kvp) kvp.Key.ToString() & ":  " + kvp.Value))
            sLoginErrors += Environment.NewLine
            connection.WebServiceManager.Dispose()
            connection = Nothing
        End If

        Return connection
    End Function

 

Message 3 of 3

pmartick
Advocate
Advocate

Requiring Admin privilege for read-only access to vault user info seems overkill. Perhaps this section of the API needs be overhauled at some point.  I'll go with another solution I found that will pull our display names from our Windows accounts instead.

 

AddReference "System.DirectoryServices.AccountManagement.dll"
'Get Display Name from Windows Account
Dim sName As String = System.DirectoryServices.AccountManagement.UserPrincipal.Current.DisplayName
'If Application Options User Name is different than Windows Display Name then update User Name
With ThisApplication : If .UserName <> sName : .UserName = sName : End If : End With

 

Thanks for the clarification.

0 Likes