private void UpdateOriginalData() { if (_editObject != null) { _originalObject = (OUGenerelEditObject)_editObject.Clone(); } else { _originalObject = new OUGenerelEditObject(); } }
/// <summary> /// Queries and fills the ldap message for the selected OU /// Gets the attribute list from AD for OU schema attribute. /// search for the attributes description, ou or name and displays them in a controls /// </summary> /// <param name="ce"></param> /// <param name="servername"></param> /// <param name="name"></param> /// <param name="dirnode"></param> public void SetData(CredentialEntry ce, string servername, string name, ADUCDirectoryNode dirnode) { try { InitializeCountryNames(); _editObject = new OUGenerelEditObject(); int ret = -1; this.dirnode = dirnode; List <LdapEntry> ldapEntries = null; ret = dirnode.LdapContext.ListChildEntriesSynchronous (dirnode.DistinguishedName, LdapAPI.LDAPSCOPE.BASE, "(objectClass=*)", null, false, out ldapEntries); if (ldapEntries == null || ldapEntries.Count == 0) { return; } LdapEntry ldapNextEntry = ldapEntries[0]; string[] attrsList = ldapNextEntry.GetAttributeNames(); if (attrsList != null) { foreach (string attr in attrsList) { string sValue = ""; LdapValue[] attrValues = ldapNextEntry.GetAttributeValues(attr, dirnode.LdapContext); if (attrValues != null && attrValues.Length > 0) { foreach (LdapValue value in attrValues) { sValue = sValue + "," + value.stringData; } } if (sValue.StartsWith(",")) { sValue = sValue.Substring(1); } if (string.Compare(sValue, "") == 0) { sValue = "<Not Set>"; } if (string.Compare(attr, "description") == 0) { this.txtDescription.Text = sValue; _editObject.Description = sValue; } if (string.Compare(attr, "street") == 0) { this.rtbStreet.Text = sValue; _editObject.Street = sValue; } if (string.Compare(attr, "l") == 0) { this.txtCity.Text = sValue; _editObject.City = sValue; } if (string.Compare(attr, "st") == 0) { this.txtstate.Text = sValue; _editObject.State = sValue; } if (string.Compare(attr, "postalCode") == 0) { this.txtZip.Text = sValue; _editObject.PostalCode = sValue; } if (string.Compare(attr, "co") == 0) { bool bEntryFound = false; for (int i = 0; i < cbcountry.Items.Count; i++) { if (sValue.Trim().ToLower().Equals(cbcountry.Items[i].ToString().Trim().ToLower())) { cbcountry.SelectedIndex = i; bEntryFound = true; break; } } if (!bEntryFound) { cbcountry.Items.Add(sValue); cbcountry.SelectedIndex = cbcountry.Items.Count - 1; } _editObject.Country = sValue; } if (string.Compare(attr, "ou") == 0) { this.userNamelabel.Text = sValue; } } } if (_editObject != null) { _originalObject = (OUGenerelEditObject)_editObject.Clone(); } else { _originalObject = new OUGenerelEditObject(); } ParentContainer.DataChanged = false; UpdateApplyButton(); } catch (Exception e) { container.ShowError(e.Message); } // throw new NotImplementedException(); }
/// <summary> /// Queries and fills the ldap message for the selected OU /// Gets the attribute list from AD for OU schema attribute. /// search for the attributes description, ou or name and displays them in a controls /// </summary> /// <param name="ce"></param> /// <param name="servername"></param> /// <param name="name"></param> /// <param name="dirnode"></param> public void SetData(CredentialEntry ce, string servername, string name, ADUCDirectoryNode dirnode) { try { InitializeCountryNames(); _editObject = new OUGenerelEditObject(); int ret = -1; this.dirnode = dirnode; List<LdapEntry> ldapEntries = null; ret = dirnode.LdapContext.ListChildEntriesSynchronous (dirnode.DistinguishedName, LdapAPI.LDAPSCOPE.BASE, "(objectClass=*)", null, false, out ldapEntries); if (ldapEntries == null || ldapEntries.Count == 0) { return; } LdapEntry ldapNextEntry = ldapEntries[0]; string[] attrsList = ldapNextEntry.GetAttributeNames(); if (attrsList != null) { foreach (string attr in attrsList) { string sValue = ""; LdapValue[] attrValues = ldapNextEntry.GetAttributeValues(attr, dirnode.LdapContext); if (attrValues != null && attrValues.Length > 0) { foreach (LdapValue value in attrValues) { sValue = sValue + "," + value.stringData; } } if (sValue.StartsWith(",")) { sValue = sValue.Substring(1); } if (string.Compare(sValue, "") == 0) { sValue = "<Not Set>"; } if (string.Compare(attr, "description") == 0) { this.txtDescription.Text = sValue; _editObject.Description = sValue; } if (string.Compare(attr, "street") == 0) { this.rtbStreet.Text = sValue; _editObject.Street = sValue; } if (string.Compare(attr, "l") == 0) { this.txtCity.Text = sValue; _editObject.City = sValue; } if (string.Compare(attr, "st") == 0) { this.txtstate.Text = sValue; _editObject.State = sValue; } if (string.Compare(attr, "postalCode") == 0) { this.txtZip.Text = sValue; _editObject.PostalCode = sValue; } if (string.Compare(attr, "co") == 0) { bool bEntryFound = false; for (int i = 0; i < cbcountry.Items.Count; i++) { if (sValue.Trim().ToLower().Equals(cbcountry.Items[i].ToString().Trim().ToLower())) { cbcountry.SelectedIndex = i; bEntryFound = true; break; } } if (!bEntryFound) { cbcountry.Items.Add(sValue); cbcountry.SelectedIndex = cbcountry.Items.Count - 1; } _editObject.Country = sValue; } if (string.Compare(attr, "ou") == 0) { this.userNamelabel.Text = sValue; } } } if (_editObject != null) { _originalObject = (OUGenerelEditObject)_editObject.Clone(); } else { _originalObject = new OUGenerelEditObject(); } ParentContainer.DataChanged = false; UpdateApplyButton(); } catch (Exception e) { container.ShowError(e.Message); } // throw new NotImplementedException(); }