private void UpdateOriginalData() { if (_editObject != null) { _originalObject = (UserGenerelEditObject)_editObject.Clone(); } else { _originalObject = new UserGenerelEditObject(); } }
/// <summary> /// Queries and fills the ldap message for the selected User /// Gets the attribute list from AD for User schema attribute. /// search for the attributes givenName, displayName, sAMAccountName, /// memberOf, sAMAccountType, userPrincipalName, sn 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 { int ret = -1; _editObject = new UserGenerelEditObject(); 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, "cn") == 0) { this.lblUserName.Text = sValue; } if (string.Compare(attr, "givenName") == 0) { this.FnametextBox.Text = sValue; _editObject.FirstName = sValue; } if (string.Compare(attr, "initials") == 0) { this.InitialTextBox.Text = sValue; _editObject.Initails = sValue; } if (string.Compare(attr, "sn") == 0) { this.LnametextBox.Text = sValue; _editObject.LastName = sValue; } if (string.Compare(attr, "displayName") == 0) { this.DisplayNametextBox.Text = sValue; _editObject.DisplayName = sValue; } if (string.Compare(attr, "description") == 0) { this.DescriptextBox.Text = sValue; _editObject.Description = sValue; } if (string.Compare(attr, "physicalDeliveryOfficeName") == 0) { this.OfficetextBox.Text = sValue; _editObject.Office = sValue; } if (string.Compare(attr, "telephoneNumber") == 0) { this.TelephonetextBox.Text = sValue; _editObject.TelephoneNumber = sValue; } if (string.Compare(attr, "mail") == 0) { this.emailtextBox.Text = sValue; _editObject.Email = sValue; } if (string.Compare(attr, "wWWHomePage") == 0) { this.webpagetextBox.Text = sValue; _editObject.WebPage = sValue; } if (string.Compare(attr, "url") == 0) { _editObject.WebPageOther = sValue; } if (string.Compare(attr, "otherTelephone") == 0) { sValue = sValue.Replace(',', ';'); _editObject.TelephoneNumberOther = sValue; } } } if (_editObject != null) { _originalObject = (UserGenerelEditObject)_editObject.Clone(); } else { _originalObject = new UserGenerelEditObject(); } ParentContainer.DataChanged = false; UpdateApplyButton(); } catch (Exception e) { Logger.LogException("UserGeneralEditPage.SetData", e); } }
/// <summary> /// Queries and fills the ldap message for the selected User /// Gets the attribute list from AD for User schema attribute. /// search for the attributes givenName, displayName, sAMAccountName, /// memberOf, sAMAccountType, userPrincipalName, sn 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 { int ret = -1; _editObject = new UserGenerelEditObject(); 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, "cn") == 0) { this.lblUserName.Text = sValue; } if (string.Compare(attr, "givenName") == 0) { this.FnametextBox.Text = sValue; _editObject.FirstName = sValue; } if (string.Compare(attr, "initials") == 0) { this.InitialTextBox.Text = sValue; _editObject.Initails = sValue; } if (string.Compare(attr, "sn") == 0) { this.LnametextBox.Text = sValue; _editObject.LastName = sValue; } if (string.Compare(attr, "displayName") == 0) { this.DisplayNametextBox.Text = sValue; _editObject.DisplayName = sValue; } if (string.Compare(attr, "description") == 0) { this.DescriptextBox.Text = sValue; _editObject.Description = sValue; } if (string.Compare(attr, "physicalDeliveryOfficeName") == 0) { this.OfficetextBox.Text = sValue; _editObject.Office = sValue; } if (string.Compare(attr, "telephoneNumber") == 0) { this.TelephonetextBox.Text = sValue; _editObject.TelephoneNumber = sValue; } if (string.Compare(attr, "mail") == 0) { this.emailtextBox.Text = sValue; _editObject.Email = sValue; } if (string.Compare(attr, "wWWHomePage") == 0) { this.webpagetextBox.Text = sValue; _editObject.WebPage = sValue; } if (string.Compare(attr, "url") == 0) { _editObject.WebPageOther = sValue; } if (string.Compare(attr, "otherTelephone") == 0) { sValue = sValue.Replace(',', ';'); _editObject.TelephoneNumberOther = sValue; } } } if (_editObject != null) { _originalObject = (UserGenerelEditObject)_editObject.Clone(); } else { _originalObject = new UserGenerelEditObject(); } ParentContainer.DataChanged = false; UpdateApplyButton(); } catch (Exception e) { Logger.LogException("UserGeneralEditPage.SetData", e); } }