Exemplo n.º 1
0
        /// <summary>
        /// 在指定的MFiles服务器中添加登陆账户
        /// </summary>
        /// <param name="user">用户对象</param>
        /// <param name="server">MFiles Server对象 </param>
        internal void CreateMFilesLoginAccount(User user, VaultServer server,
                                               MFLoginAccountType accountType, MFLicenseType licenseType)
        {
            var app = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd,
                                                      MFServerUtility.GetVaultServerLocalIp(server), server.ServerPort);

            try
            {
                var accountName = GetAccountName(user);
                var hasAccount  = MfUserUtils.HasLoginAccount(app, accountName);
                if (!hasAccount)
                {
                    var account  = new LoginAccount();
                    var fullName = user.FullName;
                    if (String.IsNullOrEmpty(fullName))
                    {
                        fullName = user.UserName;
                    }
                    account.Set(accountType, user.Domain, user.UserName,
                                MFLoginServerRole.MFLoginServerRoleLogIn, fullName, user.Email, licenseType);
                    app.LoginAccountOperations.AddLoginAccount(account);
                }
            }
            finally
            {
                app.Disconnect(); //todo 多线程时是否对其他会话有影响
            }
        }
Exemplo n.º 2
0
        public void ChangeVaultUserInfo(User user, VaultServer server)
        {
            var accountName = GetAccountName(user);
            var app         = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd,
                                                              MFServerUtility.GetVaultServerLocalIp(server), server.ServerPort);

            try
            {
                var la = MfUserUtils.GetLoginAccount(app, accountName);
                if (la == null)
                {
                    return;
                }
                var needChange = false;
                if (la.FullName != user.FullName)
                {
                    needChange  = true;
                    la.FullName = user.FullName;
                }
                if (la.EmailAddress != user.Email)
                {
                    la.EmailAddress = user.Email;
                    needChange      = true;
                }
                if (needChange)
                {
                    app.LoginAccountOperations.ModifyLoginAccount(la);
                }
            }
            finally
            {
                app.Disconnect();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 在指定的Vault中添加用户
        /// </summary>
        /// <param name="user">用户对象</param>
        /// <param name="vault">库对象</param>
        public int CreateVaultUser(User user, MFilesVault vault)
        {
            var server = vault.Server;
            var app    = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd,
                                                         MFServerUtility.GetVaultServerLocalIp(vault.Server), server.ServerPort);

            try
            {
                var mVault = app.LogInToVault(vault.Guid);

                return(CreateVaultUser(mVault, user));
            }
            finally
            {
                app.Disconnect();
            }
        }
Exemplo n.º 4
0
        public IList <MfUser> GetMFilesLoginAccounts(VaultServer server)
        {
            var res = new List <MfUser>();
            var app = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd, MFServerUtility.GetVaultServerLocalIp(server), server.ServerPort);

            try
            {
                var accs = MfUserUtils.GetLoginAccounts(app);
                res.AddRange(accs.Select(a => new MfUser
                {
                    AccountName = a.AccountName,
                    Domain      = a.DomainName,
                    UserName    = a.UserName,
                    Email       = a.EmailAddress,
                    FullName    = string.IsNullOrEmpty(a.FullName) ? a.UserName : a.FullName
                }));
            }
            finally
            {
                app.Disconnect(); //todo 多线程时是否对其他会话有影响
            }
            return(res);
        }
Exemplo n.º 5
0
        public void CreateMFilesLoginAccount(User user, VaultServer server)
        {
            var app = MFServerUtility.ConnectToServer(server.AdminName, server.AdminPwd, MFServerUtility.GetVaultServerLocalIp(server), server.ServerPort);

            try
            {
                var has = MfUserUtils.HasLoginAccount(app, GetAccountName(user));
                if (!has)
                {
                    var accType = MFLoginAccountType.MFLoginAccountTypeWindows;
                    if (string.IsNullOrEmpty(user.Domain))
                    {
                        accType = MFLoginAccountType.MFLoginAccountTypeMFiles;
                    }
                    CreateMFilesLoginAccount(user, app, accType, MFLicenseType.MFLicenseTypeConcurrentUserLicense);
                }
            }
            finally
            {
                app.Disconnect(); //todo 多线程时是否对其他会话有影响
            }
        }