//获取用户列表 public static DataTable GetUserList() { DataTable dt = new DataTable(); if (dt.Columns.Count == 0) { dt.Columns.Add("UserName"); dt.Columns.Add("UserID"); dt.Columns.Add("IsLoggedIn"); dt.Columns.Add("Vault"); dt.Columns.Add("FullName"); dt.Columns.Add("UserData"); dt.Columns.Add("Initials"); dt.Columns.Add("ObjectType"); dt.Columns.Add("Email"); } DataRow dr = null; IEdmVault5 vault = new EdmVault5(); try { vault.Login(LogName, PWD, VaultName); } catch (Exception e) { MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } IEdmUserMgr5 UserMgr = default(IEdmUserMgr5); UserMgr = (IEdmUserMgr5)vault; IEdmPos5 UserPos = default(IEdmPos5); UserPos = UserMgr.GetFirstUserPosition(); while (!UserPos.IsNull) { dr = dt.NewRow(); IEdmUser5 user5 = UserMgr.GetNextUser(UserPos); IEdmUser6 user6 = (IEdmUser6)user5; IEdmUser7 user7 = (IEdmUser7)user5; IEdmUser8 user8 = (IEdmUser8)user5; IEdmUser9 user9 = (IEdmUser9)user5; IEdmUser10 user10 = (IEdmUser10)user5; dr["UserName"] = user5.Name; dr["UserID"] = user5.ID; dr["IsLoggedIn"] = user5.IsLoggedIn; dr["Vault"] = user5.Vault.Name; dr["FullName"] = user6.FullName; dr["UserData"] = user6.UserData; dr["Initials"] = user6.Initials; dr["ObjectType"] = user6.ObjectType; dr["Email"] = user10.Email; dt.Rows.Add(dr); } return(dt); }
public object[] UserGetLoggedInUserInfo(object _vault) { #region <Debug> if (debug) { DebugPauseToAttachProcess("SWPAWHelper.Helper: " + System.Reflection.MethodInfo.GetCurrentMethod().Name); } #endregion </Debug> IEdmVault13 vault = (IEdmVault13)_vault; object[] usrInfo = new object[7]; try { if (vault == null) { usrInfo = null; return(usrInfo); } object[] groups = null; object[] tmpInfo = new object[2]; IEdmUserMgr9 usrMgr = vault.CreateUtility(EdmUtility.EdmUtil_UserMgr); IEdmUser10 user = (IEdmUser10)usrMgr.GetLoggedInUser(); user.GetGroupMemberships(out groups); // tmpInfo = new object[2]; tmpInfo[0] = @"Id";; tmpInfo[1] = user.ID; usrInfo[0] = tmpInfo; // tmpInfo = new object[2]; tmpInfo[0] = @"Initials"; tmpInfo[1] = user.Initials; usrInfo[1] = tmpInfo; // tmpInfo = new object[2]; tmpInfo[0] = @"Name"; tmpInfo[1] = user.Name; usrInfo[2] = tmpInfo; // tmpInfo = new object[2]; tmpInfo[0] = @"Full name"; tmpInfo[1] = user.FullName; usrInfo[3] = tmpInfo; // tmpInfo = new object[2]; tmpInfo[0] = @"Email"; tmpInfo[1] = user.Email; usrInfo[4] = tmpInfo; // tmpInfo = new object[2]; tmpInfo[0] = @"Logged in"; tmpInfo[1] = (user.IsLoggedIn == true ? 1.ToString() : 0.ToString());; usrInfo[5] = tmpInfo; // tmpInfo = new object[2]; tmpInfo[0] = @"Users groups"; object[] _groups = new object[0]; for (int i = 0; i < groups.Length; i++) { IEdmUserGroup8 _group = (IEdmUserGroup8)groups[i]; Array.Resize(ref _groups, _groups.Length + 1); _groups[_groups.Length - 1] = _group.Name; } tmpInfo[1] = _groups; usrInfo[6] = tmpInfo; } catch (COMException exp) { usrInfo = null; return(usrInfo); } finally { if (vault != null) { Marshal.ReleaseComObject(vault); vault = null; } } return(usrInfo); }