This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Get user's full name from Event Handler

Former Member
Former Member
Hello All

This problem was touched on in this topic (community.m-files.com/index.php but I was wondering if anyone has been able to come up with an easier way to output a user's full name using an Event Handler? I've used the below script in the BeforeDeleteObject handler:

sCurrentUser = Vault.UserOperations.GetUserAccount(CurrentUserID).LoginName


but that just gives me the SERVER/username and not the full name of the user. Is there a simple way to do this without having to create a connection to the vault with login credentials?


  • Former Member
    Former Member
    Hi Lachlan,

    you can get what you are already getting from this:
    string sCurrentUser = vault.SessionInfo.AccountName;

    To get what you would want Eg: "Lachlan McCleary" (probably!) then as far as I know the user would need to have server rights to access login accounts otherwise you will get access denied errors

    Here's some code that will load a listview with this info and highlight the current user:

    MFilesAPI.ServerLoginAccountOperations objServerLoginAccountOperations = oMFServerApp.LoginAccountOperations;
    MFilesAPI.LoginAccounts objLoginAccounts = objServerLoginAccountOperations.GetLoginAccounts();
    foreach (MFilesAPI.LoginAccount oLA in objLoginAccounts)
    {
    string sAC = oLA.AccountName;
    string sUN = oLA.UserName;
    string sFN = oLA.FullName;
    ListViewItem itmU = new ListViewItem();
    itmU.Text = sUN;
    itmU.SubItems.Add(sAC);
    itmU.SubItems.Add(sFN);
    listView1.Items.Add(itmU);
    if (vault.SessionInfo.AccountName == sAC)
    {
    itmU.ForeColor = Color.Red;
    }
    }

    There are other methods of getting that same data (full name) but they also threw errors for me (and they also probably require the current user to have server rights on login accounts)

    string sFN = vault.LoginAccountOperations.GetLoginAccount(vault.SessionInfo.AccountName).FullName;
    string sFN = vault.LoginAccountOperations.GetPersonalInformationFromDomain(vault.SessionInfo.AccountName).FullName;

    When I wrote a "Forgotten Password" option for a customer portal I used a dedicated username & pw to change the users password - which wasn't so bad as there wasn't a current user anyway as they didn't know the password :D

    Cheers James
  • Hi James,

    The instruction seems easy, but whenever I used it, I always obtain "(M-Files Server)" instead of the real user... :(


    Err.Raise MFScriptCancel, "Logged in User : " & vault.SessionInfo.AccountName

    Best regards, Jaco.
  • With "Vault.UserOperations.GetUserAccount(CurrentUserID)" it's OK.... :)

    Sorry for replying to quickly !

    Best regards.
    Jaco.