private void Button9_Click(System.Object sender, System.EventArgs e) { //Add user, Temp try { IEdmVault11 vault2 = null; if (vault1 == null) { vault1 = new EdmVault5(); } vault2 = (IEdmVault11)vault1; if (!vault1.IsLoggedIn) { vault1.LoginAuto(VaultsComboBox.Text, this.Handle.ToInt32()); } IEdmUserMgr7 UsrMgr = (IEdmUserMgr7)vault2; EdmUserData2[] UserData = new EdmUserData2[1]; UserData[0].mbsCompleteName = "Temp"; UserData[0].mbsEmail = "Temp"; UserData[0].mbsInitials = "TJ"; UserData[0].mbsUserName = "******"; UserData[0].mlFlags = (int)EdmUserDataFlags.Edmudf_GetInterface; UserData[0].mlFlags += (int)EdmUserDataFlags.Edmudf_ForceAdd; EdmSysPerm[] perms = new EdmSysPerm[3]; perms[0] = EdmSysPerm.EdmSysPerm_EditUserMgr; perms[1] = EdmSysPerm.EdmSysPerm_EditReportQuery; perms[2] = EdmSysPerm.EdmSysPerm_MandatoryVersionComments; UserData[0].moSysPerms = perms; UsrMgr.AddUsers2(UserData); string msg = ""; foreach (EdmUserData2 usr in UserData) { if (usr.mhStatus == 0) { msg += "Created user, \"" + usr.mbsUserName + "\", successfully with ID, " + usr.mlUserID.ToString() + Constants.vbCrLf; } else { msg += "Error creating user, \"" + usr.mbsUserName + "\" - " + vault2.GetErrorMessage(usr.mhStatus) + Constants.vbCrLf; } } MessageBox.Show(msg); } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Button7_Click(System.Object sender, System.EventArgs e) { //Add group, My Group try { IEdmVault11 vault2 = null; if (vault1 == null) { vault1 = new EdmVault5(); } vault2 = (IEdmVault11)vault1; if (!vault1.IsLoggedIn) { vault1.LoginAuto(VaultsComboBox.Text, this.Handle.ToInt32()); } IEdmUserMgr7 userMgr = default(IEdmUserMgr7); userMgr = (IEdmUserMgr7)vault2.CreateUtility(EdmUtility.EdmUtil_UserMgr); IEdmUser7 admin = default(IEdmUser7); admin = (IEdmUser7)userMgr.GetUser("Admin"); EdmGroupData2[] groups = new EdmGroupData2[1]; groups[0].mbAutoAdd = 0; groups[0].mbsDescription = "A group created by the API"; groups[0].mbsName = "My Group"; groups[0].mlFlags = (int)EdmGroupDataFlags.Edmgdf_GetInterface; int[] members = new int[1]; members[0] = admin.ID; groups[0].moMembers = members; EdmSysPerm[] perms = new EdmSysPerm[1]; perms[0] = EdmSysPerm.EdmSysPerm_ModifyToolbox; groups[0].moSysPerms = perms; userMgr.AddGroups2(ref groups); string msg = null; msg = ""; int idx = 0; idx = Information.LBound(groups); while ((idx <= Information.UBound(groups))) { if (groups[idx].mhStatus != 0) { msg = msg + "Error creating group, '" + groups[idx].mbsName + "' - " + vault2.GetErrorMessage(groups[idx].mhStatus) + Constants.vbLf; } else { msg = msg + "Created group, '" + groups[idx].mbsName + "', successfully with ID, " + groups[idx].mlGroupID.ToString() + Constants.vbLf; } idx = idx + 1; } vault2.MsgBox(this.Handle.ToInt32(), msg); } catch (System.Runtime.InteropServices.COMException ex) { MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }