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

How to create Login Account using VBScript?

Hello.

I want to create an EventHandler that creates a new Login Account and User in vault on creating an object in M-Files.

I am able to create users, because they are on the Vault level. But Login Accounts are Server-Level and I do not kniw how to get access there and making changes,

Is this possible to make this in VB script?

If it isn`t, then I have another idea - as I know, there is some Registry key that activates Vault-level Login accounts, but I did not find more info about this. Could you provide some manual for this topic?

Thank you!

Parents
  • Hello,

    Here is Sample code:

    Dim oServerApp: set oServerApp = CreateObject("MFilesAPI.MFilesServerApplication")
    oServerApp.Connect MFAuthTypeSpecificWindowsUser, MFilesAdmin, MFilesAdminPass, MFilesBase, MFProtocol , MFServerAddress , MFServerPort
    Set oVault = oServerApp.LogInToVault(VaultGUID)	
    
    Dim oLoginAccount: Set oLoginAccount = CreateObject("MFilesAPI.LoginAccount")
    Dim oUserAccount: Set oUserAccount = CreateObject("MFilesAPI.UserAccount")
    
    oLoginAccount.AccountType = MFLoginAccountTypeMFiles
    oLoginAccount.LicenseType = MFLicenseTypeConcurrentUserLicense
    oLoginAccount.EmailAddress = "test@test.com"
    oLoginAccount.Enabled = True
    oLoginAccount.UserName = "TestUser"
    
    oServerApp.LoginAccountOperations.AddLoginAccount oLoginAccount, "testPassword" 
    
    oUserAccount.Enabled = true
    oUserAccount.InternalUser = true
    oUserAccount.LoginName = "TestUser"
    
    oVault.UserOperations.AddUserAccount oUserAccount 

Reply
  • Hello,

    Here is Sample code:

    Dim oServerApp: set oServerApp = CreateObject("MFilesAPI.MFilesServerApplication")
    oServerApp.Connect MFAuthTypeSpecificWindowsUser, MFilesAdmin, MFilesAdminPass, MFilesBase, MFProtocol , MFServerAddress , MFServerPort
    Set oVault = oServerApp.LogInToVault(VaultGUID)	
    
    Dim oLoginAccount: Set oLoginAccount = CreateObject("MFilesAPI.LoginAccount")
    Dim oUserAccount: Set oUserAccount = CreateObject("MFilesAPI.UserAccount")
    
    oLoginAccount.AccountType = MFLoginAccountTypeMFiles
    oLoginAccount.LicenseType = MFLicenseTypeConcurrentUserLicense
    oLoginAccount.EmailAddress = "test@test.com"
    oLoginAccount.Enabled = True
    oLoginAccount.UserName = "TestUser"
    
    oServerApp.LoginAccountOperations.AddLoginAccount oLoginAccount, "testPassword" 
    
    oUserAccount.Enabled = true
    oUserAccount.InternalUser = true
    oUserAccount.LoginName = "TestUser"
    
    oVault.UserOperations.AddUserAccount oUserAccount 

Children
No Data