public void Create(Group group,string Position,Category category)
        {
            if (string.IsNullOrEmpty(group.Name))
            {
                return;
            }
            DirectoryEntry Entry = Get("(&(OU="+Position+"))");
            string nn = "CN=";
            if (category == Category.organizationalUnit)
            {
                Entry = GetDirectoryObject();
                nn = "OU=";
            }
            if (Entry == null)
            {
                throw new ArgumentException("未找到创建组的组织单元");
            }
            DirectoryEntry groupEntry = Entry.Children.Add(nn+ group.Name, category.ToString());
            if (!string.IsNullOrEmpty(group.Descriptions))
            {
                groupEntry.Properties["description"].Add(group.Descriptions);
            }

            groupEntry.CommitChanges();
            groupEntry.Close();
            Entry.Close();
        }
Example #2
0
 public static string TreeToString( Group Group)
 {
     var value = string.Empty;
     if (Group == null || string.IsNullOrEmpty(Group.Name))
     {
         return null;
     }
     value += "{ label:'"+Group.Name+"',children:[";
     foreach (Group item in Group.Children)
     {
         value += TreeToString(item);
     }
     value += "]},";
     return value;
 }
 public ActionResult CreateGroup(Group group,string Position,Category category)
 {
     Core.ADManager.Create(group,Position,category);
     return RedirectToAction("Group");
 }
Example #4
0
 private static Group GetTree(DirectoryEntry Entry)
 {
     var group = new Group();
     var name = GetProperty(Entry, "name");
     if (string.IsNullOrEmpty(name) || IgnoresList.Contains(name))
     {
         return null;
     }
     group.Name = name;
     group.Descriptions = GetProperty(Entry, "description");
     DateTime time;
     DateTime.TryParse(GetProperty(Entry, "whenCreated"), out time);
     group.CreateTime = time;
     foreach (DirectoryEntry item in Entry.Children)
     {
         var temp = GetTree(item);
         if (temp != null)
         {
             group.Children.Add(temp);
         }
     }
     return group;
 }
Example #5
0
 public static Group GetTree()
 {
     var group = new Group();
     var admin = GetDirectoryObject();
     group.Name = GetProperty(admin, "name");
     group.Descriptions = GetProperty(admin, "description");
     DateTime time;
     DateTime.TryParse(GetProperty(admin, "whenCreated"), out time);
     group.CreateTime = time;
     foreach(DirectoryEntry child in  admin.Children)
     {
         var temp = GetTree(child);
         if (temp != null)
         {
             group.Children.Add(temp);
         }
     }
     return group;
 }
 protected ActionResult JsonGroup(Group group)
 {
     string json = "["+Group.TreeToString(group)+"]";
     return Json(json,JsonRequestBehavior.AllowGet);
 }
 public Group GetTree()
 {
     Group group = new Group();
     DirectoryEntry Admin = GetDirectoryObject();
     group.Name = GetProperty(Admin, "name");
     group.Descriptions = GetProperty(Admin, "description");
     DateTime time;
     DateTime.TryParse(GetProperty(Admin, "whenCreated"), out time);
     group.CreateTime = time;
     List<string> ignores = Core.IgnoreManager.GetCompose();
     foreach (DirectoryEntry child in Admin.Children)
     {
         Group value = GetTree(child, ignores);
         if (value != null)
         {
             group.Children.Add(value);
         }
     }
     return group;
 }