1 Reply Latest reply on Dec 17, 2012 1:18 PM by Michael Dekoning

    AddUser2 not working as expected, or I'm doing something wrong.

    Benjamin Abshire



      I am trying to add a new user to EPDM using the API call AddUser2. The source code I'm using is directly from the 2012 API_GB.chm help guide and is repeated below. When I try to run the code I get an "Access is Denied" error at the userMgr.AddUser2 call in the CreateUser sub. I have created several test vaults and configured them to use different Login methods (and to make sure I hadn't enabled/disabled some permission in existing vaults) but nothing I do seams to alleviate this problem. Does anyone have any suggestions or sample code that works for them? Other pertinent information: I’m using Visual Studio 2010, building a .Net 4.0 assembly, and referencing PDMWorks Enterprise 2012 Type library (COM) version 5.15. Thanks for your help.


      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

          Dim Vault As EdmVault5

          Vault = New EdmVault5

          'Log into Vault

          Vault.Login("admin", "password", "test_vault")


      End Sub


      Private Sub CreateUser(ByVal vault As IEdmVault11)
      On Error GoTo ErrHand

        'Get the interface of the user manager
        Dim userMgr As IEdmUserMgr7
        userMgr = vault.CreateUtility(EdmUtility.EdmUtil_UserMgr)

        'Create an array with the users we want to add (just one in this case)
        Dim users(0) As EdmUserData2
        users(0).mbsCompleteName = "Ronald Smith"
        users(0).mbsEmail = "ron@ronscompany.com"
        users(0).mbsInitials = "RS"
        users(0).mbsPassword = "secret"
        users(0).mbsUserData = "Some arbitrary string"
        users(0).mbsUserName = "rsmith"
        users(0).mlFlags = EdmUserDataFlags.Edmudf_GetInterface
        Dim perms(1) As EdmSysPerm
        perms(0) = EdmSysPerm.EdmSysPerm_ModifyToolbox
        perms(1) = EdmSysPerm.EdmSysPerm_ModifySearchForms
        users(0).moSysPerms = perms

        'Add the users
        userMgr.AddUsers2(users) ‘Error occurs here

        'Check errors
        Dim msg As String
        msg = ""
        Dim idx As Integer
        idx = LBound(users)
        While (idx <= UBound(users))
          If users(idx).mhStatus <> 0 Then
            msg = msg + "Error creating user '" + users(idx).mbsUserName + "' - " + vault.GetErrorMessage(users(idx).mhStatus) + vbLf
            msg = msg + "Created user '" + users(idx).mpoUser.Name + "' successfully. ID=" + CStr(users(idx).mpoUser.ID) + vbLf
          End If
          idx = idx + 1
        End While

        vault.MsgBox(Me.Handle.ToInt32, msg)
        Exit Sub

        vault.MsgBox(Me.Handle.ToInt32, vault.GetErrorMessage(Err.Number))
      End Sub