0 Replies Latest reply on May 19, 2017 6:30 PM by Sean Donnelly

    PDM Pro C# Get Logged In User Menu Command

    Sean Donnelly

      Hi, I have the below code. I simplified it to get the example easy. I'm trying to figure out how to grab the username of the logged-in user. I assume the issue is somewhere around my "(IEdmUserMgr5)myVault".

       

      if (poCmd.mlCmdID == 1000) //This makes sure the menu command ID was 1000, which means your addin was the one called  
                              {
                                  
                                  IEdmVault12 myVault = (IEdmVault12)poCmd.mpoVault; //Cast the vault to an Iedmvault12 object for latest functionality 
      
      
                                  IEdmUserMgr5 userMgr = (IEdmUserMgr5)myVault
                                  IEdmUser5 user = (IEdmUser5)myVault;
                                  user = userMgr.GetLoggedInUser();
                                  MessageBox.Show(user.Name);
      
      
                                  if (user.Name != "admin")
                                  {
                                      MessageBox.Show("This add-in is in Beta Mode, you do not have permission to use it.");
                                      return;
                                  }
      }