/// <summary> /// Converts a Princpal object (or anything descended from one) into the appropriate AD*** object. /// UserPrincipal -> ADUser /// GroupPrincipal -> ADGroup /// </summary> /// <param name="source"></param> /// <returns></returns> public ADObject toADObject(Principal source) { ADObject result = null; if (source is UserPrincipal) { result = new ADUser(_connection, (UserPrincipal)source); } else if (source is GroupPrincipal) { result = new ADGroup(_connection, (GroupPrincipal)source); } else { throw new NotImplementedException("This type of principal has not yet been implemented"); } return result; }
private void main_Load(object sender, EventArgs e) { ADUser temp = new ADUser(ad); ADField.Items.Add(""); foreach (string field in temp.Fields.OrderBy(i=>i)) { ADField.Items.Add(field); } ADField.SelectedIndex = 0; }