Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API - obtaining Vault's credentials from the Inventor API

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
cadfish1
3535 Views, 9 Replies

API - obtaining Vault's credentials from the Inventor API

Is there a way of obtaining Vault's credentials from the Inventor API?  I'm trying to create a command in my Inventor add-in that needs to login to the vault to gather some infomation.  I can create my own login screen if need be but why have the user login again if the credentials can somehow be obtained from Inventor. Also, if I create my own login screen then wouldn't the user be logged in twice (i.e. Inventor normal vault login mechanism plus my login code) which I assume will consume another license?

9 REPLIES 9
Message 2 of 10
Redmond.D
in reply to: cadfish1

There is an old post that tells you how to get this information.  As far as I know, the trick still works.

http://forums.autodesk.com/t5/Autodesk-Vault/SecurityHeader-in-Inventor/m-p/1713249/

 

 



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 10
cadfish1
in reply to: Redmond.D

The code you mention eailer in this thread does not work for 2011 and I can't user the VaultServiceManager to get the SercurityHeader until 2012.  Besides the references you've mentioned in an earlier thread, the Security object also requires Connectivity.Proxies.utils to be referenced which I've done.  I can't find a reference in any of the loading libraries to ServiceAttributeTest (Object Browser) so I'm assuming it used to be in one of the two libraries that you've said requires referencing (just a guess).  In any case, are there any changes I can make to get the SercurityHeader in 2011?

 

!temp1.jpg

Message 4 of 10
Redmond.D
in reply to: cadfish1

In Vault 2011, the security header you want to use is Autodesk.Connectivity.WebServices.DocumentSvc.SecurityHeader.

 

In Vault 2010 and earlier, there was no Autodesk.Connectivity.WebServices.dll so each project had to generate their own web service objects.  As a result, the namespaces would be different for each project.  The original code was from a sample application called ServiceAttributeTest.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 5 of 10
cadfish1
in reply to: Redmond.D

Thanks Doug but I need a little more help.  Can you explain exactly how (code) to obtain the security header from Inventor?  I assume that ServiceAttributeTest class contains the SecurityService object which code can access to obtain the seucrity header to apply to other vault service objects (like DocumentSvc).  But how exactly do I extract the security header from Inventor in 2011?

 

In the code below I've attempt to utilize Rene's code from the thread you've mentioned earlier in this conversation but I receive the following error message.  I did have to modify Rene's code because 2011 doesn't seem to have a ServiceManager object any longer.

 

!temp1.jpg

 

Imports Autodesk.Connectivity.WebServices
Imports System.IO
Imports Connectivity.InventorAddin.EdmAddin
Imports Connectivity.Proxies.Security
Imports Connectivity.Proxies.Utils

Public Class EditedOutOfTurn
    Private moDocSvc As Autodesk.Connectivity.WebServices.DocumentService
    Private msLocalRoot As String
    Private Const HOST As String = "L1429783"
    Private Shared MAX_FILE_SIZE As Long = 50 * 1024 * 1024    ' 50 MB 

    'Private Sub EditedOutOfTurn_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
    Private Sub EditedOutOfTurn_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        Dim oDocument As Inventor.Document
        Dim sRelativePathFile As String
        Dim sVaultPathFile As String
        Dim aoFiles() As Autodesk.Connectivity.WebServices.File
        Dim oFile As Autodesk.Connectivity.WebServices.File
        Dim oAllReferencedDocuments As Inventor.DocumentsEnumerator
        Dim sFile As String
        Dim c As New CRC32
        Dim crc As Integer = 0

        ListView1.Items.Clear() 'Shouldn't be necessary because this form is unloaded when done so the Shown event will trigger (triggers only once)


        moDocSvc = New DocumentService()
        moDocSvc.Url = "http://" & Connectivity.InventorAddin.EdmAddin.EdmSecurity.Instance.GetEdmSecurityContext.RemoteHost & "/AutodeskDM/Services/DocumentService.asmx"
        moDocSvc.SecurityHeaderValue = New DocumentSvc.SecurityHeader()
        Dim security As EdmSecurity = EdmSecurity.Instance
        If security.IsSignedIn() Then
            moDocSvc.SecurityHeaderValue.Ticket = security.SecurityContext.Ticket
            moDocSvc.SecurityHeaderValue.UserId = security.SecurityContext.UserID
        End If

        Dim sLocalRoot As String
        If moDocSvc.GetEnforceWorkingFolder Then
            sLocalRoot = moDocSvc.GetRequiredWorkingFolderLocation
            If Mid(sLocalRoot, Len(sLocalRoot)) = "\" Then sLocalRoot = Mid(sLocalRoot, 1, Len(sLocalRoot) - 1)
        Else
            'C:\Documents and Settings\UserName\Application Data\Autodesk\VaultCommon\Servers\Services_Security_1_25_2010\l1429783\Vaults\PCI PS Vault\Objects\WorkingFolders.xml
            'Vault Version - This one looks a bit strange, for example Vault 2010 has a value of "Services_Security_1_26_2009".  It's basically a code that changes with each release.  Therefore client settings are tied to a specific Vault version.
            'We have 3 working folders (C:\Local Workspace, M:\PCI Inventor Library\Content Center Files, 
            'M:\PCI Inventor Library\Purchased Components) so an array of these folder should be created
            'Also, I came across a user that used to have a local path for our design 
            'in "C:\Local Workspace\CAD Data" instead of "C:\Local Workspace".
            '2012 has GetWorkingFolder
            sLocalRoot = "C:\Local Workspace"
        End If

        oDocument = goInvApp.ActiveDocument

        sFile = oDocument.FullFileName
        sRelativePathFile = Mid(oDocument.FullFileName, Len(sLocalRoot) + 1)
        sVaultPathFile = Replace("$" & sRelativePathFile, "\", "/")
        Dim asFiles2() As String = {sVaultPathFile}
        aoFiles = moDocSvc.FindLatestFilesByPaths(asFiles2)
        oFile = aoFiles(0)
        If oFile.Id = -1 Then
            'collect the list of files that could not be found.
        Else
            crc = c.GetCrc32(oDocument.FullFileName)
            If oFile.Cksum <> crc Then ListView1.Items.Add(oDocument.FullFileName)
        End If

        oAllReferencedDocuments = oDocument.AllReferencedDocuments()
        For Each oDoc As Inventor.Document In oAllReferencedDocuments
            sRelativePathFile = Mid(oDoc.FullFileName, Len(sLocalRoot) + 1)
            sVaultPathFile = Replace("$" & sRelativePathFile, "\", "/")
            Dim asFiles() As String = {sVaultPathFile}
            aoFiles = moDocSvc.FindLatestFilesByPaths(asFiles)
            oFile = aoFiles(0)
            If oFile.Id = -1 Then
                'collect the list of files that could not be found.
            Else
                crc = c.GetCrc32(oDoc.FullFileName)
                If oFile.Cksum <> crc Then ListView1.Items.Add(oDoc.FullFileName)
            End If
        Next
    End Sub
    
End Class

 

Message 6 of 10
Redmond.D
in reply to: cadfish1

The error states that the appliation, Inventor, "could not load file or assembly Autodesk.Connectivity.WebServices".

So you need to put a copy of Autodesk.Connectivity.WebServices.dll in a place where Inventor can load it.  You can try putting it next to your add in.  If that doesn't work, try putting it in Inventor's bin directory.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 7 of 10
cadfish1
in reply to: Redmond.D

You da man!  Thanks Doug.  I've copied it to the add-in folder and now it works.

 

I'm confused though, the Inventor addin references Autodesk.Connectivity.WebServices.dll from a location beneath My Documents where I have some VB.NET projects.  Why can't the Inventor addin use that copy (it know where it's located)? 

Message 8 of 10
Redmond.D
in reply to: cadfish1

You'll have to ask the Inventor team why the DLL didn't load from the original location.  Loading DLL references is very complex and each appliation gets to set rules about how and where DLLs get loaded.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 9 of 10
Anonymous
in reply to: Redmond.D

I seem to be having issues with Connectivity.InventorAddin.EdmAddin.EdmSecurity on Windows 7 64-bit using Visual Basic with dotNet 4.0.  I have taken a sample add-in and have added the logic for acquiring the Vault UserID and Ticket information when the user is previously logged in.

 

Windows 7 64-bit - Vault 2011 -  Inventor 2011

---------------

Dim security As EdmSecurity = EdmSecurity.Instance

 

MsgBox("IsSignedIn : " & security.IsSignedIn)
MsgBox("Ticket: " & security.GetEdmCCSecurityContext.Ticket)
MsgBox("UserID : " & security.GetEdmCCSecurityContext.UserID)
MsgBox("Host : " & security.GetEdmCCSecurityContext.RemoteHost)

---------------

 

Using dotNet 3.5 under x86 or x64 compile, the logic functions appropriately.

 

Using dotNet 4.0, the logic always returns EdmSecurity.IsSignedIn is False and accessing the Ticket gives "Object does not reference an instance of an object..." error.

 

I am wanting to use dotNet 4.0 and I am wondering if this is a known issue with any resolution.

 

Thanks.

 

Kevin Mette

 

 

Message 10 of 10
AlexFielder
in reply to: Anonymous

I'm pretty sure that even though Inventor 2012 supports .NET 4.0 addins, the Vault SDK dlls only allow .NET 3.5 - at least that's my experience anyway.

 

Perhaps in the next release they'll allow .NET 4.0??

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report