private void SaveRecord() { _Storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted); foreach (ListViewItem item in lvwStoreGroups.Items) { #region update checked items only, not selected if (item.Checked) { _SelectedItems.Add(item); #region 立即 save IAzManStoreGroup storeGroup = _Store.GetStoreGroup(item.SubItems[0].Text); IAzManAuthorization auth = _AuthItem.CreateAuthorization( new SqlAzManSID(storeGroup.SID.ToString(), this._CurrentOwnerSidWhereDefined == WhereDefined.Store), this._CurrentOwnerSidWhereDefined, new SqlAzManSID(storeGroup.SID.ToString(), true), WhereDefined.Store, AuthorizationType.Neutral, null, null); #endregion } #endregion } _Storage.CommitTransaction(); }
private void SaveRecord() { try { _Storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted); foreach (ListViewItem item in lvwStoreGroups.Items) { #region update checked items only, not selected if (item.Checked) { _SelectedItems.Add(item); #region 立即 save IAzManStoreGroup sg = _Store.GetStoreGroup(item.SubItems[0].Text); _StoreGroup.CreateStoreGroupMember(sg.SID, WhereDefined.Store, _IsMember); #endregion } #endregion } _Storage.CommitTransaction(); } catch (Exception ex) { _Storage.RollBackTransaction(); throw (ex); } }
private void Form_Load(object sender, EventArgs e) { _Storage = (IAzManStorage)Session["storage"]; if (Session["selectedObject"] as IAzManStore != null) { _Store = Session["selectedObject"] as IAzManStore; } if (Session["selectedObject"] as IAzManStoreGroup != null) { _StoreGroup = this.Session["selectedObject"] as IAzManStoreGroup; _Store = _StoreGroup.Store; } if (Session["selectedObject"] as IAzManApplicationGroup != null) { _ApplicationGroup = Session["selectedObject"] as IAzManApplicationGroup; _Application = _ApplicationGroup.Application; _Store = _Application.Store; } _Mode = Mode.Update; SetAttributes(); LoadTab(); }
private void raiseStoreGroupLDAPQueryUpdated(IAzManStoreGroup storeGroup, string oldLDapQuery) { if (this.StoreGroupLDAPQueryUpdated != null) { this.StoreGroupLDAPQueryUpdated(storeGroup, oldLDapQuery); } }
private void raiseStoreGroupMemberDeleted(IAzManStoreGroup ownerStoreGroup, IAzManSid sid) { if (this.StoreGroupMemberDeleted != null) { this.StoreGroupMemberDeleted(ownerStoreGroup, sid); } }
private bool detectLoop(IAzManStoreGroup storeGroupToAdd) { if (storeGroupToAdd.GroupType == GroupType.LDapQuery) { return(false); } bool loopDetected = false; IAzManStoreGroupMember[] membersOfStoreGroupToAdd = storeGroupToAdd.GetStoreGroupAllMembers(); foreach (IAzManStoreGroupMember member in membersOfStoreGroupToAdd) { if (member.WhereDefined == WhereDefined.Store) { IAzManStoreGroup storeGroupMember = this.store.GetStoreGroup(member.SID); if (storeGroupMember.SID.StringValue == this.sid.StringValue) { return(true); } else { if (this.detectLoop(storeGroupMember)) { loopDetected = true; } } } } return(loopDetected); }
private void raiseStoreGroupMemberCreated(IAzManStoreGroup storeGroup, IAzManStoreGroupMember memberCreated) { if (this.StoreGroupMemberCreated != null) { this.StoreGroupMemberCreated(storeGroup, memberCreated); } }
private void raiseStoreGroupRenamed(IAzManStoreGroup storeGroup, string oldName) { if (this.StoreGroupRenamed != null) { this.StoreGroupRenamed(storeGroup, oldName); } }
private void raiseStoreGroupCreated(IAzManStore store, IAzManStoreGroup storeGroupCreated) { if (this.StoreGroupCreated != null) { this.StoreGroupCreated(store, storeGroupCreated); } }
private void raiseStoreGroupUpdated(IAzManStoreGroup storeGroup, IAzManSid oldSid, string oldDescription, GroupType oldGroupType) { if (this.StoreGroupUpdated != null) { this.StoreGroupUpdated(storeGroup, oldSid, oldDescription, oldGroupType); } }
/// <summary> /// Creates the store group member. /// </summary> /// <param name="sid">The object owner.</param> /// <param name="whereDefined">Where member is defined.</param> /// <param name="isMember">if set to <c>true</c> [is member].</param> /// <returns></returns> public IAzManStoreGroupMember CreateStoreGroupMember(IAzManSid sid, WhereDefined whereDefined, bool isMember) { if (this.groupType != GroupType.Basic) { throw new InvalidOperationException("Method not supported for LDAP Groups"); } if (this.store.Storage.Mode == NetSqlAzManMode.Administrator && whereDefined == WhereDefined.Local) { throw new SqlAzManException("Cannot create Store Group members defined on local in Administrator Mode"); } //Loop detection if (whereDefined == WhereDefined.Store) { IAzManStoreGroup storeGroupToAdd = this.store.GetStoreGroup(sid); if (this.detectLoop(storeGroupToAdd)) { throw new SqlAzManException(String.Format("Cannot add '{0}'. A loop has been detected.", storeGroupToAdd.Name)); } } int retV = this.db.StoreGroupMemberInsert(this.store.StoreId, this.storeGroupId, sid.BinaryValue, (byte)whereDefined, isMember); IAzManStoreGroupMember result = new SqlAzManStoreGroupMember(this.db, this, retV, sid, whereDefined, isMember, this.ens); this.raiseStoreGroupMemberCreated(this, result); if (this.ens != null) { this.ens.AddPublisher(result); } return(result); }
/// <summary> /// Creates the store group. /// </summary> /// <param name="storeGroupSid">The store group sid.</param> /// <param name="name">The name.</param> /// <param name="description">The description.</param> /// <param name="lDapQuery">The ldap query.</param> /// <param name="groupType">Type of the group.</param> /// <returns></returns> public IAzManStoreGroup CreateStoreGroup(IAzManSid storeGroupSid, string name, string description, string lDapQuery, GroupType groupType) { try { if (DirectoryServices.DirectoryServicesUtils.TestLDAPQuery(lDapQuery)) { this.db.StoreGroupInsert(this.storeId, storeGroupSid.BinaryValue, name, description, lDapQuery, (byte)groupType); IAzManStoreGroup result = this.GetStoreGroup(name); this.raiseStoreGroupCreated(this, result); if (this.ens != null) { this.ens.AddPublisher(result); } this.storeGroups = null; //Force cache refresh return(result); } else { throw new ArgumentException("LDAP Query syntax error or unavailable Domain.", "lDapQuery"); } } catch (System.Data.SqlClient.SqlException sqlex) { if (sqlex.Number == 2601) //Index Duplicate Error { throw SqlAzManException.StoreGroupDuplicateException(name, this, sqlex); } else { throw SqlAzManException.GenericException(sqlex); } } }
private void btnNonMembersRemove_Click(object sender, EventArgs e) { foreach (ListViewItem lvi in this.lsvNonMembers.SelectedItems) { if ((lvi.Tag as IAzManStoreGroup) != null) { IAzManStoreGroup lviTag = (IAzManStoreGroup)lvi.Tag; this.NonMembersToRemove.Add(new GenericMember(lviTag.Name, lviTag.SID, WhereDefined.Store)); this.modified = true; } else if ((lvi.Tag as IAzManStoreGroupMember) != null) { IAzManStoreGroupMember lviTag = (IAzManStoreGroupMember)lvi.Tag; this.NonMembersToRemove.Add(new GenericMember(lviTag.SID.StringValue, lviTag.SID, WhereDefined.LDAP)); this.modified = true; } else if ((lvi.Tag as GenericMember) != null) { GenericMember lviTag = (GenericMember)lvi.Tag; if (this.NonMembersToAdd.Remove(lviTag.sid.StringValue)) { this.modified = true; } } } this.RefreshStoreGroupProperties(); if (this.lsvNonMembers.Items.Count == 0) { this.btnNonMembersRemove.Enabled = false; } this.HourGlass(false); }
private void Form_Load(object sender, EventArgs e) { _Storage = (IAzManStorage)Session["storage"]; if (Session["selectedObject"] as IAzManStore != null) { _Store = this.Session["selectedObject"] as IAzManStore; } if (Session["selectedObject"] as IAzManStoreGroup != null) { _StoreGroup = this.Session["selectedObject"] as IAzManStoreGroup; _Store = _StoreGroup.Store; } //_Store = (IAzManStore)Session["selectedObject"]; _Mode = (_Store == null) ? Mode.Create : Mode.Update; SetAttributes(); SetToolBar(); if (_Mode == Mode.Update) { LoadRecord(); } }
private ListViewItem CreateStoreListViewItem(IAzManStoreGroup member) { ListViewItem lvi = new ListViewItem(); lvi.Tag = member; lvi.Text = member.Name; lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_Store")); return(lvi); }
internal SqlAzManStoreGroupMember(NetSqlAzManStorageDataContext db, IAzManStoreGroup storeGroup, int storeGroupMemberId, IAzManSid sid, WhereDefined whereDefined, bool isMember, SqlAzManENS ens) { this.db = db; this.storeGroup = storeGroup; this.storeGroupMemberId = storeGroupMemberId; this.sid = sid; this.whereDefined = whereDefined; this.isMember = isMember; this.ens = ens; }
private ListViewItem CreateStoreListViewItem(IAzManStoreGroup member) { ListViewItem lvi = new ListViewItem(); lvi.Tag = member; lvi.Text = member.Name; lvi.SubItems.Add("Store"); lvi.SubItems.Add(member.SID.StringValue); return(lvi); }
protected void btnNonMembersRemove_Click(object sender, EventArgs e) { for (int i = 0; i < this.dgNonMembers.Rows.Count; i++) { if (((System.Web.UI.WebControls.CheckBox) this.dgNonMembers.Rows[i].FindControl("chkSelect")).Checked) { string sid = this.dgNonMembers.Rows[i].Cells[3].Text; foreach (ListViewItem lvi in this.lsvNonMembers.Items) { if (lvi.SubItems[1].Text == sid) { lvi.Selected = true; break; } } } } foreach (ListViewItem lvi in this.lsvNonMembers.Items) { if (lvi.Selected) { if ((lvi.Tag as IAzManStoreGroup) != null) { IAzManStoreGroup lviTag = (IAzManStoreGroup)lvi.Tag; this.NonMembersToRemove.Add(new GenericMember(lviTag.Name, lviTag.SID, WhereDefined.Store)); this.modified = true; } if ((lvi.Tag as IAzManApplicationGroup) != null) { IAzManApplicationGroup lviTag = (IAzManApplicationGroup)lvi.Tag; this.NonMembersToRemove.Add(new GenericMember(lviTag.Name, lviTag.SID, WhereDefined.Application)); this.modified = true; } else if ((lvi.Tag as IAzManApplicationGroupMember) != null) { IAzManApplicationGroupMember lviTag = (IAzManApplicationGroupMember)lvi.Tag; this.NonMembersToRemove.Add(new GenericMember(lviTag.SID.StringValue, lviTag.SID, WhereDefined.LDAP)); this.modified = true; } else if ((lvi.Tag as GenericMember) != null) { GenericMember lviTag = (GenericMember)lvi.Tag; if (this.NonMembersToAdd.Remove(lviTag.sid.StringValue)) { this.modified = true; } } lvi.Selected = false; } } this.RefreshApplicationGroupProperties(); }
protected void btnOk_Click(object sender, EventArgs e) { try { IAzManStoreGroup storeGroup = this.store.CreateStoreGroup(SqlAzManSID.NewSqlAzManSid(), this.txtName.Text.Trim(), this.txtDescription.Text.Trim(), String.Empty, (this.rbtBasic.Checked ? GroupType.Basic : GroupType.LDapQuery)); this.Session["FindChildNodeText"] = storeGroup.Name; this.closeWindow(true); } catch (Exception ex) { this.ShowError(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { this.storage = this.Session["storage"] as IAzManStorage; this.storeGroup = this.Session["storeGroup"] as IAzManStoreGroup; this.store = this.Session["store"] as IAzManStore; this.Text = "Store Groups List"; this.Description = this.Text; this.Title = this.Text; if (!Page.IsPostBack) { this.RefreshStoreList(); } }
public StoreGroupScopeNode(IAzManStoreGroup storeGroup) : base(true) { this.storeGroup = storeGroup; // Create a message view for the Store Group node. MMC.MmcListViewDescription lvlStoreGroup = new MMC.MmcListViewDescription(); lvlStoreGroup.DisplayName = Globalization.MultilanguageResource.GetString("ListView_Msg150"); lvlStoreGroup.ViewType = typeof(StoreGroupListView); lvlStoreGroup.Options = MMC.MmcListViewOptions.AllowUserInitiatedModeChanges; this.ViewDescriptions.Clear(); this.ViewDescriptions.Add(lvlStoreGroup); this.ViewDescriptions.DefaultIndex = 0; this.RenderStoreGroupScopeNode(); }
private void btnOk_Click(object sender, EventArgs e) { this.HourGlass(true); try { this.storeGroup = this.store.CreateStoreGroup(SqlAzManSID.NewSqlAzManSid(), this.txtName.Text.Trim(), this.txtDescription.Text.Trim(), String.Empty, (this.rbtBasic.Checked ? GroupType.Basic : GroupType.LDapQuery)); this.HourGlass(false); this.DialogResult = DialogResult.OK; } catch (Exception ex) { this.HourGlass(false); this.DialogResult = DialogResult.None; this.ShowError(ex.Message, Globalization.MultilanguageResource.GetString("frmNewStoreGroup_Msg20")); } }
/// <summary> /// Create a Full Storage through .NET code /// </summary> private void CreateFullStorage() { // USER MUST BE A MEMBER OF SQL DATABASE ROLE: NetSqlAzMan_Administrators //Sql Storage connection string string sqlConnectionString = "data source=(local);initial catalog=NetSqlAzManStorage;user id=netsqlazmanuser;password=password"; //Create an instance of SqlAzManStorage class IAzManStorage storage = new SqlAzManStorage(sqlConnectionString); //Open Storage Connection storage.OpenConnection(); //Begin a new Transaction storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted); //Create a new Store IAzManStore newStore = storage.CreateStore("My Store", "Store description"); //Create a new Basic StoreGroup IAzManStoreGroup newStoreGroup = newStore.CreateStoreGroup(SqlAzManSID.NewSqlAzManSid(), "My Store Group", "Store Group Description", String.Empty, GroupType.Basic); //Retrieve current user SID IAzManSid mySid = new SqlAzManSID(((System.Threading.Thread.CurrentPrincipal.Identity as WindowsIdentity) ?? WindowsIdentity.GetCurrent()).User); //Add myself as sid of "My Store Group" IAzManStoreGroupMember storeGroupMember = newStoreGroup.CreateStoreGroupMember(mySid, WhereDefined.Local, true); //Create a new Application IAzManApplication newApp = newStore.CreateApplication("New Application", "Application description"); //Create a new Role IAzManItem newRole = newApp.CreateItem("New Role", "Role description", ItemType.Role); //Create a new Task IAzManItem newTask = newApp.CreateItem("New Task", "Task description", ItemType.Task); //Create a new Operation IAzManItem newOp = newApp.CreateItem("New Operation", "Operation description", ItemType.Operation); //Add "New Operation" as a sid of "New Task" newTask.AddMember(newOp); //Add "New Task" as a sid of "New Role" newRole.AddMember(newTask); //Create an authorization for myself on "New Role" IAzManAuthorization auth = newRole.CreateAuthorization(mySid, WhereDefined.Local, mySid, WhereDefined.Local, AuthorizationType.AllowWithDelegation, null, null); //Create a custom attribute IAzManAttribute <IAzManAuthorization> attr = auth.CreateAttribute("New Key", "New Value"); //Create an authorization for DB User "Andrea" on "New Role" IAzManAuthorization auth2 = newRole.CreateAuthorization(mySid, WhereDefined.Local, storage.GetDBUser("Andrea").CustomSid, WhereDefined.Local, AuthorizationType.AllowWithDelegation, null, null); //Commit transaction storage.CommitTransaction(); //Close connection storage.CloseConnection(); }
/// <summary> /// Gets the store group. /// </summary> /// <param name="sid">The object owner.</param> /// <returns></returns> public IAzManStoreGroup GetStoreGroup(IAzManSid sid) { StoreGroupsResult sgr; if ((sgr = (from t in this.db.StoreGroups() where t.ObjectSid == sid.BinaryValue && t.StoreId == this.storeId select t).FirstOrDefault()) != null) { IAzManStoreGroup result = this.GetStoreGroup(sgr.Name); if (this.ens != null) { this.ens.AddPublisher(result); } return(result); } else { throw SqlAzManException.StoreGroupNotFoundException(sid.StringValue, this, null); } }
private DataRow AddStoreDataRow(IAzManStoreGroup member) { DataRow dr = this.dtAuthorizations.NewRow(); dr["Owner"] = this.currentOwnerName; dr["OwnerSID"] = this.currentOwnerSid; dr["Name"] = member.Name; dr["MemberType"] = this.RenderMemberType(MemberType.StoreGroup, member.SID); dr["MemberTypeEnum"] = MemberType.StoreGroup; dr["ObjectSID"] = member.SID; dr["WhereDefined"] = WhereDefined.Store.ToString(); dr["WhereDefinedEnum"] = WhereDefined.Store; dr["AuthorizationType"] = this.RenderAuthorizationType(AuthorizationType.Neutral); dr["AuthorizationTypeEnum"] = AuthorizationType.Neutral; dr["ValidFrom"] = DBNull.Value; dr["ValidTo"] = DBNull.Value; this.dtAuthorizations.Rows.Add(dr); return(dr); }
private void Form_Load(object sender, EventArgs e) { _Storage = (IAzManStorage)Session["storage"]; if (Session["selectedObject"] as IAzManStore != null) { _Store = Session["selectedObject"] as IAzManStore; } if (Session["selectedObject"] as IAzManStoreGroup != null) { _StoreGroup = this.Session["selectedObject"] as IAzManStoreGroup; _Store = _StoreGroup.Store; } SetAttributes(); SetToolBar(); LoadList(); }
private void SaveRecord() { try { _Storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted); IAzManStoreGroup storeGroup = _Store.CreateStoreGroup( SqlAzManSID.NewSqlAzManSid(), txtName.Text.Trim(), txtDescription.Text.Trim(), String.Empty, (radBasic.Checked ? GroupType.Basic : GroupType.LDapQuery)); _Storage.CommitTransaction(); _IsDirty = true; } catch (Exception ex) { _Storage.RollBackTransaction(); throw ex; } }
private void raiseStoreGroupUpdated(IAzManStoreGroup storeGroup, IAzManSid oldSid, string oldDescription, GroupType oldGroupType) { if (this.StoreGroupUpdated != null) this.StoreGroupUpdated(storeGroup, oldSid, oldDescription, oldGroupType); }
/// <summary> /// Adds an IAzManStoreGroup publisher. /// </summary> /// <param name="publisher">The storeGroup.</param> internal void AddPublisher(IAzManStoreGroup publisher) { publisher.StoreGroupMemberCreated += new StoreGroupMemberCreatedDelegate(delegate(IAzManStoreGroup storeGroup, IAzManStoreGroupMember storeGroupMembercreated) { if (this.StoreGroupMemberCreated != null) this.StoreGroupMemberCreated(storeGroup, storeGroupMembercreated); }); publisher.StoreGroupDeleted += new StoreGroupDeletedDelegate(delegate(IAzManStore ownerStore, string storeGroupName) { if (this.StoreGroupDeleted != null) this.StoreGroupDeleted(ownerStore, storeGroupName); }); publisher.StoreGroupLDAPQueryUpdated += new StoreGroupLDAPQueryUpdatedDelegate(delegate(IAzManStoreGroup storeGroup, string oldLDapQuery) { if (this.StoreGroupLDAPQueryUpdated != null) this.StoreGroupLDAPQueryUpdated(storeGroup, oldLDapQuery); }); publisher.StoreGroupRenamed += new StoreGroupRenamedDelegate(delegate(IAzManStoreGroup storeGroup, string oldName) { if (this.StoreGroupRenamed != null) this.StoreGroupRenamed(storeGroup, oldName); }); publisher.StoreGroupUpdated += new StoreGroupUpdatedDelegate(delegate(IAzManStoreGroup storeGroup, IAzManSid oldSid, string oldDescription, GroupType oldGroupType) { if (this.StoreGroupUpdated != null) this.StoreGroupUpdated(storeGroup, oldSid, oldDescription, oldGroupType); }); }
void SqlAzManENS_StoreGroupCreated(IAzManStore store, IAzManStoreGroup storeGroupCreated) { logging.WriteInfo(this, String.Format("ENS Event: {0}\r\n\r\nStore: {1}\r\nStore Group Created: {2}\r\n", "StoreGroupCreated", store.ToString(), storeGroupCreated.ToString())); }
private void raiseStoreGroupMemberCreated(IAzManStoreGroup storeGroup, IAzManStoreGroupMember memberCreated) { if (this.StoreGroupMemberCreated != null) this.StoreGroupMemberCreated(storeGroup, memberCreated); }
private void raiseStoreGroupMemberDeleted(IAzManStoreGroup ownerStoreGroup, IAzManSid sid) { if (this.StoreGroupMemberDeleted != null) this.StoreGroupMemberDeleted(ownerStoreGroup, sid); }
private DataRow AddStoreDataRow(IAzManStoreGroup member) { DataRow dr = this.dtAuthorizations.NewRow(); dr["Owner"] = this.currentOwnerName; dr["OwnerSID"] = this.currentOwnerSid; dr["Name"] = member.Name; dr["MemberType"] = this.RenderMemberType(MemberType.StoreGroup, member.SID); dr["MemberTypeEnum"] = MemberType.StoreGroup; dr["ObjectSID"] = member.SID; dr["WhereDefined"] = WhereDefined.Store.ToString(); dr["WhereDefinedEnum"] = WhereDefined.Store; dr["AuthorizationType"] = this.RenderAuthorizationType(AuthorizationType.Neutral); dr["AuthorizationTypeEnum"] = AuthorizationType.Neutral; dr["ValidFrom"] = DBNull.Value; dr["ValidTo"] = DBNull.Value; this.dtAuthorizations.Rows.Add(dr); return dr; }
void SqlAzManENS_StoreGroupMemberDeleted(IAzManStoreGroup ownerStoreGroup, IAzManSid sid) { logging.WriteInfo(this, String.Format("ENS Event: {0}\r\n\r\nStore Group: {1}\r\nSID: {2}\r\n", "StoreGroupMemberDeleted", ownerStoreGroup.ToString(), sid)); }
void SqlAzManENS_StoreGroupRenamed(IAzManStoreGroup storeGroup, string oldName) { logging.WriteInfo(this, String.Format("ENS Event: {0}\r\n\r\nStore Group: {1}\r\nOld Name: {2}\r\n", "StoreGroupRenamed", storeGroup.ToString(), oldName)); }
void SqlAzManENS_StoreGroupUpdated(IAzManStoreGroup storeGroup, IAzManSid oldSid, string oldDescription, GroupType oldGroupType) { logging.WriteInfo(this, String.Format("ENS Event: {0}\r\n\r\nStore Group: {1}\r\nOld SID: {2}\r\nOld Description: {3}\r\nOld Group Type: {4}\r\n", "StoreGroupUpdated", storeGroup.ToString(), oldSid, oldDescription, oldGroupType)); }
private IAzManSid[] getCachedLDAPQueryResults(IAzManStoreGroup storeGroup) { string key = "storeGroup " + storeGroup.StoreGroupId.ToString(); if (!this.ldapQueryResults.ContainsKey(key)) { lock (ldapQueryResults) { if (!this.ldapQueryResults.ContainsKey(key)) { //LDAP Group var ldapQueryResult = storeGroup.ExecuteLDAPQuery(); if (ldapQueryResult != null) { IAzManSid[] membersResults = new IAzManSid[ldapQueryResult.Count]; for (int i = 0; i < ldapQueryResult.Count; i++) { membersResults[i] = new SqlAzManSID((byte[])ldapQueryResult[i].Properties["objectSid"][0]); } this.ldapQueryResults.Add(key, membersResults); } } } } return (IAzManSid[])this.ldapQueryResults[key]; }
protected void Page_Load(object sender, EventArgs e) { this.storage = this.Session["storage"] as IAzManStorage; if (this.Session["selectedObject"] as IAzManStore != null) { this.store = this.Session["selectedObject"] as IAzManStore; } if (this.Session["selectedObject"] as IAzManStoreGroup != null) { this.storeGroup = this.Session["selectedObject"] as IAzManStoreGroup; this.Session["storeGroup"] = this.storeGroup; this.Session["store"] = this.storeGroup.Store; } this.Text = "Store Group properties" + (this.storeGroup != null ? ": " + this.storeGroup.Name : String.Empty); this.Description = "Store Group properties"; this.Title = this.Text; if (!Page.IsPostBack) { this.MembersToAdd = new GenericMemberCollection(); this.MembersToRemove = new GenericMemberCollection(); this.NonMembersToAdd = new GenericMemberCollection(); this.NonMembersToRemove = new GenericMemberCollection(); this.lsvMembers = new ListView(); this.lsvNonMembers = new ListView(); this.mnuTab.Items[1].Selected = true; //0 is blank this.mnuTab_MenuItemClick(this, new System.Web.UI.WebControls.MenuEventArgs(this.mnuTab.Items[1])); this.txtName.Text = this.storeGroup.Name; this.txtDescription.Text = this.storeGroup.Description; this.txtGroupType.Text = (this.storeGroup.GroupType == GroupType.Basic ? "Basic group" : "LDAP Query group"); if (this.storeGroup.GroupType == GroupType.Basic) { this.btnMembersAddStoreGroup.Enabled = this.btnNonMembersAddStoreGroup.Enabled = this.storeGroup.Store.HasStoreGroups(); this.mnuTab.Items.RemoveAt(3); this.mnuTab.Items.RemoveAt(2); this.lsvMembers.Items.Clear(); this.lsvNonMembers.Items.Clear(); this.setImage("StoreApplicationGroup_32x32.gif"); } else { this.mnuTab.Items.RemoveAt(7); this.mnuTab.Items.RemoveAt(6); this.mnuTab.Items.RemoveAt(5); this.mnuTab.Items.RemoveAt(4); this.setImage("WindowsQueryLDAPGroup_32x32.gif"); } this.RefreshStoreGroupProperties(); this.saveSessionVariables(); this.modified = false; this.txtName.Focus(); } else { this.loadSessionVariables(); if (this.Session["selectedStoreGroups"] != null) { if (this.mnuTab.SelectedValue == "Members") this.btnMembersAddStoreGroups_Click(this, EventArgs.Empty); else if (this.mnuTab.SelectedValue == "Non Members") this.btnNonMembersAddStoreGroup_Click(this, EventArgs.Empty); } if (this.Session["selectedDBUsers"] != null) { if (this.mnuTab.SelectedValue == "Members") this.btnMembersAddDBUsers_Click(this, EventArgs.Empty); else if (this.mnuTab.SelectedValue == "Non Members") this.btnNonMembersAddDBUsers_Click(this, EventArgs.Empty); } if (this.Session["selectedADObjects"] != null) { if (this.mnuTab.SelectedValue == "Members") this.btnMembersAddWindowsUsersAndGroups_Click(this, EventArgs.Empty); else if (this.mnuTab.SelectedValue == "Non Members") this.btnNonMembersAddWindowsUsersAndGroup_Click(this, EventArgs.Empty); } } }
private ListViewItem CreateStoreListViewItem(IAzManStoreGroup member) { ListViewItem lvi = new ListViewItem(); lvi.Tag = member; lvi.Text = member.Name; lvi.SubItems.Add("Store"); lvi.SubItems.Add(member.SID.StringValue); return lvi; }
private void ImportFromAzMan(string azManStorePath, string netSqlAzManStoreName) { Microsoft.Interop.Security.AzRoles.AzAuthorizationStore azstore = null; string tempFileName = Path.Combine(Environment.GetEnvironmentVariable("temp", EnvironmentVariableTarget.Machine), String.Format("AzMan{0}.xml", Guid.NewGuid())); try { this.storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted); string storeDescription = String.Format("Store imported from AzMan Store:" + " ({0}) - {1}", azManStorePath, DateTime.Now.ToString()); IAzManStore store = this.storage.CreateStore(netSqlAzManStoreName, storeDescription); azstore = new AzAuthorizationStoreClass(); if (this.rbtStoreFile.Checked) { this.FileUpload1.SaveAs(tempFileName); azManStorePath = String.Format("msxml://{0}", tempFileName); } azstore.Initialize(2, azManStorePath, null); #region Store Groups //Store Groups foreach (IAzApplicationGroup azStoreGroup in azstore.ApplicationGroups) { //Store Groups Definition if (azStoreGroup.Type == (int)tagAZ_PROP_CONSTANTS.AZ_GROUPTYPE_BASIC) { //Basic store.CreateStoreGroup(SqlAzManSID.NewSqlAzManSid(), azStoreGroup.Name, azStoreGroup.Description, String.Empty, GroupType.Basic); } else if (azStoreGroup.Type == (int)tagAZ_PROP_CONSTANTS.AZ_GROUPTYPE_LDAP_QUERY) { //LDap store.CreateStoreGroup(SqlAzManSID.NewSqlAzManSid(), azStoreGroup.Name, azStoreGroup.Description, azStoreGroup.LdapQuery, GroupType.LDapQuery); } } //Store Groups Members foreach (IAzApplicationGroup azStoreGroup in azstore.ApplicationGroups) { if (azStoreGroup.Type == (int)tagAZ_PROP_CONSTANTS.AZ_GROUPTYPE_BASIC) { //Basic IAzManStoreGroup storeGroup = store.GetStoreGroup(azStoreGroup.Name); //Store Group Members - Members Store Group object[] azStoreGroupMembers = azStoreGroup.AppMembers as object[]; if (azStoreGroupMembers != null) { foreach (string azStoreGroupMember in azStoreGroupMembers) { IAzManStoreGroup member = store.GetStoreGroup(azStoreGroupMember); storeGroup.CreateStoreGroupMember(member.SID, WhereDefined.Store, true); } } //Store Group Non-Members - Non-Members Store Group object[] azStoreGroupNonMembers = azStoreGroup.AppNonMembers as object[]; if (azStoreGroupNonMembers != null) { foreach (string azStoreGroupNonMember in azStoreGroupNonMembers) { IAzManStoreGroup nonMember = store.GetStoreGroup(azStoreGroupNonMember); storeGroup.CreateStoreGroupMember(nonMember.SID, WhereDefined.Store, false); } } //Store Group Members - Windows NT Account object[] azStoreGroupWindowsMembers = azStoreGroup.Members as object[]; if (azStoreGroupWindowsMembers != null) { foreach (string azStoreWindowsMember in azStoreGroupWindowsMembers) { IAzManSid sid = new SqlAzManSID(azStoreWindowsMember); string memberName; bool isLocal; DirectoryServicesWebUtils.GetMemberInfo(sid.StringValue, out memberName, out isLocal); storeGroup.CreateStoreGroupMember(sid, isLocal ? WhereDefined.Local : WhereDefined.LDAP, true); } } //Store Group NonMembers - Windows NT Account object[] azStoreGroupWindowsNonMembers = azStoreGroup.NonMembers as object[]; if (azStoreGroupWindowsNonMembers != null) { foreach (string azStoreWindowsNonMember in azStoreGroupWindowsNonMembers) { IAzManSid sid = new SqlAzManSID(azStoreWindowsNonMember); string memberName; bool isLocal; DirectoryServicesWebUtils.GetMemberInfo(sid.StringValue, out memberName, out isLocal); storeGroup.CreateStoreGroupMember(sid, isLocal ? WhereDefined.Local : WhereDefined.LDAP, false); } } } } #endregion Store Groups #region Applications //Applications foreach (IAzApplication azApplication in azstore.Applications) { IAzManApplication application = store.CreateApplication(azApplication.Name, azApplication.Description); #region Application Groups //Store Groups foreach (IAzApplicationGroup azApplicationGroup in azApplication.ApplicationGroups) { //Application Groups Definition if (azApplicationGroup.Type == (int)tagAZ_PROP_CONSTANTS.AZ_GROUPTYPE_BASIC) { //Basic application.CreateApplicationGroup(SqlAzManSID.NewSqlAzManSid(), azApplicationGroup.Name, azApplicationGroup.Description, String.Empty, GroupType.Basic); } else if (azApplicationGroup.Type == (int)tagAZ_PROP_CONSTANTS.AZ_GROUPTYPE_LDAP_QUERY) { //LDap application.CreateApplicationGroup(SqlAzManSID.NewSqlAzManSid(), azApplicationGroup.Name, azApplicationGroup.Description, azApplicationGroup.LdapQuery, GroupType.LDapQuery); } } //Application Groups Members foreach (IAzApplicationGroup azApplicationGroup in azApplication.ApplicationGroups) { if (azApplicationGroup.Type == (int)tagAZ_PROP_CONSTANTS.AZ_GROUPTYPE_BASIC) { //Basic IAzManApplicationGroup applicationGroup = application.GetApplicationGroup(azApplicationGroup.Name); //Application Group Members - Members Group object[] azStoreGroupMembers = azApplicationGroup.AppMembers as object[]; if (azStoreGroupMembers != null) { foreach (string azGroupMember in azStoreGroupMembers) { IAzManStoreGroup storemember; try { storemember = store.GetStoreGroup(azGroupMember); } catch (SqlAzManException) { storemember = null; } IAzManApplicationGroup appmember; try { appmember = application.GetApplicationGroup(azGroupMember); } catch (SqlAzManException) { appmember = null; } if (storemember != null) { applicationGroup.CreateApplicationGroupMember(storemember.SID, WhereDefined.Store, true); } else { applicationGroup.CreateApplicationGroupMember(appmember.SID, WhereDefined.Application, true); } } } //Application Group Non-Members - Non-Members Group object[] azStoreGroupNonMembers = azApplicationGroup.AppNonMembers as object[]; if (azStoreGroupNonMembers != null) { foreach (string azGroupNonMember in azStoreGroupNonMembers) { IAzManStoreGroup storenonMember; try { storenonMember = store.GetStoreGroup(azGroupNonMember); } catch (SqlAzManException) { storenonMember = null; } IAzManApplicationGroup appnonMember; try { appnonMember = application.GetApplicationGroup(azGroupNonMember); } catch (SqlAzManException) { appnonMember = null; } if (storenonMember != null) { applicationGroup.CreateApplicationGroupMember(storenonMember.SID, WhereDefined.Store, false); } else { applicationGroup.CreateApplicationGroupMember(appnonMember.SID, WhereDefined.Application, false); } } } //Application Group Members - Windows NT Account object[] azApplicationGroupWindowsMembers = azApplicationGroup.Members as object[]; if (azApplicationGroupWindowsMembers != null) { foreach (string azApplicationWindowsMember in azApplicationGroupWindowsMembers) { IAzManSid sid = new SqlAzManSID(azApplicationWindowsMember); string memberName; bool isLocal; DirectoryServicesWebUtils.GetMemberInfo(sid.StringValue, out memberName, out isLocal); applicationGroup.CreateApplicationGroupMember(sid, isLocal ? WhereDefined.Local : WhereDefined.LDAP, true); } } //Application Group NonMembers - Windows NT Account object[] azApplicationGroupWindowsNonMembers = azApplicationGroup.NonMembers as object[]; if (azApplicationGroupWindowsNonMembers != null) { foreach (string azApplicationWindowsNonMember in azApplicationGroupWindowsNonMembers) { IAzManSid sid = new SqlAzManSID(azApplicationWindowsNonMember); string memberName; bool isLocal; DirectoryServicesWebUtils.GetMemberInfo(sid.StringValue, out memberName, out isLocal); applicationGroup.CreateApplicationGroupMember(sid, isLocal ? WhereDefined.Local : WhereDefined.LDAP, false); } } } } #endregion Application Groups //Without Scopes IAzTasks tasks = azApplication.Tasks as IAzTasks; if (tasks != null) { foreach (IAzTask azTask in tasks) { if (azTask.IsRoleDefinition == 1) { IAzManItem item = application.CreateItem(azTask.Name, azTask.Description, ItemType.Role); } else { IAzManItem item = application.CreateItem(azTask.Name, azTask.Description, ItemType.Task); } } } IAzOperations operations = azApplication.Operations as IAzOperations; if (operations != null) { foreach (IAzOperation azOperation in operations) { application.CreateItem(azOperation.Name, azOperation.Description, ItemType.Operation); } } //Build Item Hierarchy if (tasks != null) { foreach (IAzTask azTask in tasks) { this.SetHirearchy(null, azApplication, azTask.Name, application); } } //Scopes foreach (IAzScope azScope in azApplication.Scopes) { azApplication.OpenScope(azScope.Name, null); IAzTasks tasksOfScope = azScope.Tasks as IAzTasks; if (tasksOfScope != null) { foreach (IAzTask azTask in tasksOfScope) { if (azTask.IsRoleDefinition == 1) { IAzManItem item = application.CreateItem(azTask.Name, azTask.Description, ItemType.Role); } else { IAzManItem item = application.CreateItem(azTask.Name, azTask.Description, ItemType.Task); } } } //Build Item Hierarchy if (tasksOfScope != null) { foreach (IAzTask azTask in tasksOfScope) { this.SetHirearchy(azScope, azApplication, azTask.Name, application); } } } //Authorizations on Roles without Scopes AuthorizationType defaultAuthorization = AuthorizationType.AllowWithDelegation; IAzRoles azRoles = azApplication.Roles; foreach (IAzRole azRole in azRoles) { IAzManItem item; try { item = application.GetItem(azRole.Name); } catch (SqlAzManException) { item = null; } if (item == null) { item = application.CreateItem(azRole.Name, azRole.Description, ItemType.Role); } //Store & Application Groups Authorizations foreach (string member in (object[])azRole.AppMembers) { IAzManStoreGroup storeGroup; try { storeGroup = application.Store.GetStoreGroup(member); } catch (SqlAzManException) { storeGroup = null; } IAzManApplicationGroup applicationGroup; try { applicationGroup = application.GetApplicationGroup(member); } catch (SqlAzManException) { applicationGroup = null; } if (storeGroup != null) { item.CreateAuthorization(this.currentOwnerSid, this.currentOwnerSidWhereDefined, storeGroup.SID, WhereDefined.Store, defaultAuthorization, null, null); } else if (applicationGroup != null) { item.CreateAuthorization(this.currentOwnerSid, this.currentOwnerSidWhereDefined, applicationGroup.SID, WhereDefined.Application, defaultAuthorization, null, null); } } //Windows Users & Groups Authorizations foreach (string sSid in (object[])azRole.Members) { IAzManSid sid = new SqlAzManSID(sSid); string memberName; bool isLocal; DirectoryServicesWebUtils.GetMemberInfo(sid.StringValue, out memberName, out isLocal); item.CreateAuthorization(this.currentOwnerSid, this.currentOwnerSidWhereDefined, sid, isLocal ? WhereDefined.Local : WhereDefined.LDAP, defaultAuthorization, null, null); } } //Authorizations on Roles with Scopes foreach (IAzScope azScope in azApplication.Scopes) { IAzRoles azRolesWithScopes = azScope.Roles; foreach (IAzRole azRole in azRolesWithScopes) { IAzManItem item; try { item = application.GetItem(azRole.Name); } catch (SqlAzManException) { item = null; } if (item == null) { item = application.CreateItem(azRole.Name, azRole.Description, ItemType.Role); } //Store & Application Groups Authorizations foreach (string member in (object[])azRole.AppMembers) { IAzManStoreGroup storeGroup; try { storeGroup = application.Store.GetStoreGroup(member); } catch (SqlAzManException) { storeGroup = null; } IAzManApplicationGroup applicationGroup; try { applicationGroup = application.GetApplicationGroup(member); } catch (SqlAzManException) { applicationGroup = null; } if (storeGroup != null) { item.CreateAuthorization(this.currentOwnerSid, this.currentOwnerSidWhereDefined, storeGroup.SID, WhereDefined.Store, defaultAuthorization, null, null); } else if (applicationGroup != null) { item.CreateAuthorization(this.currentOwnerSid, this.currentOwnerSidWhereDefined, applicationGroup.SID, WhereDefined.Application, defaultAuthorization, null, null); } } //Windows Users & Groups Authorizations foreach (string sSid in (object[])azRole.Members) { IAzManSid sid = new SqlAzManSID(sSid); string memberName; bool isLocal; DirectoryServicesWebUtils.GetMemberInfo(sid.StringValue, out memberName, out isLocal); item.CreateAuthorization(this.currentOwnerSid, this.currentOwnerSidWhereDefined, sid, isLocal ? WhereDefined.Local : WhereDefined.LDAP, defaultAuthorization, null, null); } } } //try //{ // azstore.CloseApplication(azApplication.Name, 0); //} //catch //{ // //PorkAround: COM Is a mistery //} } #endregion Applications if (storage.TransactionInProgress) { storage.CommitTransaction(); } } catch { if (storage.TransactionInProgress) { storage.RollBackTransaction(); } throw; } finally { if (azstore != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(azstore); File.Delete(tempFileName); azstore = null; } } }
void SqlAzManENS_StoreGroupMemberCreated(IAzManStoreGroup storeGroup, IAzManStoreGroupMember memberCreated) { logging.WriteInfo(this, String.Format("ENS Event: {0}\r\n\r\nStore Group: {1}\r\nMember Created: {2}\r\n", "StoreGroupMemberCreated", storeGroup.ToString(), memberCreated.ToString())); }
private ListViewItem CreateStoreListViewItem(IAzManStoreGroup member) { ListViewItem lvi = new ListViewItem(); lvi.Tag = member; lvi.Text = member.Name; lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_Store")); return lvi; }
private bool detectLoop(IAzManStoreGroup storeGroupToAdd) { if (storeGroupToAdd.GroupType == GroupType.LDapQuery) return false; bool loopDetected = false; IAzManStoreGroupMember[] membersOfStoreGroupToAdd = storeGroupToAdd.GetStoreGroupAllMembers(); foreach (IAzManStoreGroupMember member in membersOfStoreGroupToAdd) { if (member.WhereDefined == WhereDefined.Store) { IAzManStoreGroup storeGroupMember = this.store.GetStoreGroup(member.SID); if (storeGroupMember.SID.StringValue == this.sid.StringValue) { return true; } else { if (this.detectLoop(storeGroupMember)) { loopDetected = true; } } } } return loopDetected; }
private void raiseStoreGroupRenamed(IAzManStoreGroup storeGroup, string oldName) { if (this.StoreGroupRenamed != null) this.StoreGroupRenamed(storeGroup, oldName); }
void SqlAzManENS_StoreGroupLDAPQueryUpdated(IAzManStoreGroup storeGroup, string oldLDapQuery) { logging.WriteInfo(this, String.Format("ENS Event: {0}\r\n\r\nStore Group: {1}\r\nOld LDAP Query: {2}\r\n", "StoreGroupLDAPQueryUpdated", storeGroup.ToString(), oldLDapQuery)); }
private void raiseStoreGroupLDAPQueryUpdated(IAzManStoreGroup storeGroup, string oldLDapQuery) { if (this.StoreGroupLDAPQueryUpdated != null) this.StoreGroupLDAPQueryUpdated(storeGroup, oldLDapQuery); }
/// <summary> /// Imports the specified XML reader. /// </summary> /// <param name="xmlNode">The XML node.</param> /// <param name="includeWindowsUsersAndGroups">if set to <c>true</c> [include windows users and groups].</param> /// <param name="includeDBUsers">if set to <c>true</c> [include DB users].</param> /// <param name="includeAuthorizations">if set to <c>true</c> [include authorizations].</param> /// <param name="mergeOptions">The merge options.</param> public void ImportChildren(XmlNode xmlNode, bool includeWindowsUsersAndGroups, bool includeDBUsers, bool includeAuthorizations, SqlAzManMergeOptions mergeOptions) { //Create Store Groups foreach (XmlNode node in xmlNode.ChildNodes) { if (node.Name == "Attributes") { foreach (XmlNode childNode in node.ChildNodes) { if (childNode.Name == "Attribute") { if (!this.Attributes.ContainsKey(childNode.Attributes["Key"].Value)) { IAzManAttribute <IAzManStore> newStoreAttribute = this.CreateAttribute(childNode.Attributes["Key"].Value, childNode.Attributes["Value"].Value); } else { this.Attributes[childNode.Attributes["Key"].Value].Update(childNode.Attributes["Key"].Value, childNode.Attributes["Value"].Value); } } } } else if (node.Name == "Attribute") { if (!this.Attributes.ContainsKey(node.Attributes["Key"].Value)) { IAzManAttribute <IAzManStore> newStoreAttribute = this.CreateAttribute(node.Attributes["Key"].Value, node.Attributes["Value"].Value); } else { this.Attributes[node.Attributes["Key"].Value].Update(node.Attributes["Key"].Value, node.Attributes["Value"].Value); } } if (node.Name == "Permissions") { foreach (XmlNode childNode in node.ChildNodes) { if (childNode.Name == "Managers") { foreach (XmlNode childChildNode in childNode.ChildNodes) { if (childChildNode.Name == "Manager") { this.GrantAccessAsManager(childChildNode.Attributes["SqlUserOrRole"].Value); } } } else if (childNode.Name == "Users") { foreach (XmlNode childChildNode in childNode.ChildNodes) { if (childChildNode.Name == "User") { this.GrantAccessAsUser(childChildNode.Attributes["SqlUserOrRole"].Value); } } } else if (childNode.Name == "Readers") { foreach (XmlNode childChildNode in childNode.ChildNodes) { if (childChildNode.Name == "Reader") { this.GrantAccessAsReader(childChildNode.Attributes["SqlUserOrRole"].Value); } } } } } if (node.Name == "StoreGroups") { foreach (XmlNode childNode in node.ChildNodes) { if (childNode.Name == "StoreGroup") { GroupType groupType = GroupType.Basic; if (childNode.Attributes["GroupType"].Value == GroupType.LDapQuery.ToString()) { groupType = GroupType.LDapQuery; } IAzManStoreGroup storeGroup = null; string sid = null; if (this.StoreGroups.ContainsKey(childNode.Attributes["Name"].Value)) { storeGroup = this.StoreGroups[childNode.Attributes["Name"].Value]; sid = storeGroup.SID.StringValue; //Change Store Group SID MergeUtilities.changeSid(childNode.OwnerDocument.DocumentElement, childNode.Attributes["Sid"].Value, sid); } else { sid = SqlAzManSID.NewSqlAzManSid().StringValue; storeGroup = this.CreateStoreGroup(new SqlAzManSID(sid), childNode.Attributes["Name"].Value, childNode.Attributes["Description"].Value, childNode.Attributes["LDAPQuery"].Value, groupType); //Change Store Group SID MergeUtilities.changeSid(childNode.OwnerDocument.DocumentElement, childNode.Attributes["Sid"].Value, sid); } //newStoreGroup.ImportChildren(childNode, includeWindowsUsersAndGroups, includeAuthorizations); } } } else if (node.Name == "StoreGroup") { GroupType groupType = GroupType.Basic; if (node.Attributes["GroupType"].Value == GroupType.LDapQuery.ToString()) { groupType = GroupType.LDapQuery; } IAzManStoreGroup storeGroup = null; string sid = null; if (this.StoreGroups.ContainsKey(node.Attributes["Name"].Value)) { storeGroup = this.StoreGroups[node.Attributes["Name"].Value]; sid = storeGroup.SID.StringValue; //Change Store Group SID MergeUtilities.changeSid(node.OwnerDocument.DocumentElement, node.Attributes["Sid"].Value, sid); } else { sid = SqlAzManSID.NewSqlAzManSid().StringValue; storeGroup = this.CreateStoreGroup(new SqlAzManSID(sid), node.Attributes["Name"].Value, node.Attributes["Description"].Value, node.Attributes["LDAPQuery"].Value, groupType); //Change Store Group SID MergeUtilities.changeSid(node.OwnerDocument.DocumentElement, node.Attributes["Sid"].Value, sid); } //newStoreGroup.ImportChildren(node, includeWindowsUsersAndGroups, includeAuthorizations); } } //Create Applications & Store Group Members foreach (XmlNode node in xmlNode.ChildNodes) { System.Windows.Forms.Application.DoEvents(); if (node.Name == "Applications") { foreach (XmlNode childNode in node.ChildNodes) { if (childNode.Name == "Application") { IAzManApplication newApplication = this.Applications.ContainsKey(childNode.Attributes["Name"].Value) ? this.Applications[childNode.Attributes["Name"].Value] : this.CreateApplication(childNode.Attributes["Name"].Value, childNode.Attributes["Description"].Value); newApplication.ImportChildren(childNode, includeWindowsUsersAndGroups, includeDBUsers, includeAuthorizations, mergeOptions); } } } else if (node.Name == "Application") { IAzManApplication newApplication = this.Applications.ContainsKey(node.Attributes["Name"].Value) ? this.Applications[node.Attributes["Name"].Value] : this.CreateApplication(node.Attributes["Name"].Value, node.Attributes["Description"].Value); newApplication.ImportChildren(node, includeWindowsUsersAndGroups, includeDBUsers, includeAuthorizations, mergeOptions); } else if (node.Name == "StoreGroups") { foreach (XmlNode childNode in node.ChildNodes) { if (childNode.Name == "StoreGroup") { GroupType groupType = GroupType.Basic; if (childNode.Attributes["GroupType"].Value == GroupType.LDapQuery.ToString()) { groupType = GroupType.LDapQuery; } if (groupType == GroupType.Basic) { IAzManStoreGroup newStoreGroup = this.StoreGroups[childNode.Attributes["Name"].Value]; newStoreGroup.ImportChildren(childNode, includeWindowsUsersAndGroups, includeDBUsers, includeAuthorizations, mergeOptions); } } } } else if (node.Name == "StoreGroup") { GroupType groupType = GroupType.Basic; if (node.Attributes["GroupType"].Value == GroupType.LDapQuery.ToString()) { groupType = GroupType.LDapQuery; } if (groupType == GroupType.Basic) { IAzManStoreGroup newStoreGroup = this.StoreGroups[node.Attributes["Name"].Value]; newStoreGroup.ImportChildren(node, includeWindowsUsersAndGroups, includeDBUsers, includeAuthorizations, mergeOptions); } } } this.applications = null; //Force refresh }
internal static SqlAzManException StoreGroupMemberNotFoundException(string memberName, IAzManStoreGroup storeGroup, Exception innerException) { SqlAzManException ex = new SqlAzManException(String.Format("Store Group Member '{0}' not found. Store '{1}', Store Group '{2}'.", memberName, storeGroup.Store.Name, storeGroup.Name), innerException); addParameter(ex, "Store name", storeGroup.Store.Name); addParameter(ex, "Store Group name", storeGroup.Name); addParameter(ex, "Member name", memberName); return ex; }
protected void Page_Load(object sender, EventArgs e) { this.storage = this.Session["storage"] as IAzManStorage; if (this.Session["selectedObject"] as IAzManStore != null) { this.store = this.Session["selectedObject"] as IAzManStore; } if (this.Session["selectedObject"] as IAzManStoreGroup != null) { this.storeGroup = this.Session["selectedObject"] as IAzManStoreGroup; this.Session["storeGroup"] = this.storeGroup; this.Session["store"] = this.storeGroup.Store; } this.Text = "Store Group properties" + (this.storeGroup != null ? ": " + this.storeGroup.Name : String.Empty); this.Description = "Store Group properties"; this.Title = this.Text; if (!Page.IsPostBack) { this.MembersToAdd = new GenericMemberCollection(); this.MembersToRemove = new GenericMemberCollection(); this.NonMembersToAdd = new GenericMemberCollection(); this.NonMembersToRemove = new GenericMemberCollection(); this.lsvMembers = new ListView(); this.lsvNonMembers = new ListView(); this.mnuTab.Items[1].Selected = true; //0 is blank this.mnuTab_MenuItemClick(this, new System.Web.UI.WebControls.MenuEventArgs(this.mnuTab.Items[1])); this.txtName.Text = this.storeGroup.Name; this.txtDescription.Text = this.storeGroup.Description; this.txtGroupType.Text = (this.storeGroup.GroupType == GroupType.Basic ? "Basic group" : "LDAP Query group"); if (this.storeGroup.GroupType == GroupType.Basic) { this.btnMembersAddStoreGroup.Enabled = this.btnNonMembersAddStoreGroup.Enabled = this.storeGroup.Store.HasStoreGroups(); this.mnuTab.Items.RemoveAt(3); this.mnuTab.Items.RemoveAt(2); this.lsvMembers.Items.Clear(); this.lsvNonMembers.Items.Clear(); this.setImage("StoreApplicationGroup_32x32.gif"); } else { this.mnuTab.Items.RemoveAt(7); this.mnuTab.Items.RemoveAt(6); this.mnuTab.Items.RemoveAt(5); this.mnuTab.Items.RemoveAt(4); this.setImage("WindowsQueryLDAPGroup_32x32.gif"); } this.RefreshStoreGroupProperties(); this.saveSessionVariables(); this.modified = false; this.txtName.Focus(); } else { this.loadSessionVariables(); if (this.Session["selectedStoreGroups"] != null) { if (this.mnuTab.SelectedValue == "Members") { this.btnMembersAddStoreGroups_Click(this, EventArgs.Empty); } else if (this.mnuTab.SelectedValue == "Non Members") { this.btnNonMembersAddStoreGroup_Click(this, EventArgs.Empty); } } if (this.Session["selectedDBUsers"] != null) { if (this.mnuTab.SelectedValue == "Members") { this.btnMembersAddDBUsers_Click(this, EventArgs.Empty); } else if (this.mnuTab.SelectedValue == "Non Members") { this.btnNonMembersAddDBUsers_Click(this, EventArgs.Empty); } } if (this.Session["selectedADObjects"] != null) { if (this.mnuTab.SelectedValue == "Members") { this.btnMembersAddWindowsUsersAndGroups_Click(this, EventArgs.Empty); } else if (this.mnuTab.SelectedValue == "Non Members") { this.btnNonMembersAddWindowsUsersAndGroup_Click(this, EventArgs.Empty); } } } }