public ActionResult CreateGroupTemplate(Guid id) { try { LcpsAdsGroup ou = new LcpsAdsGroup(id); GroupTemplate t = new GroupTemplate(); t.GroupId = id; t.TemplateName = ou.Name; if (string.IsNullOrEmpty(ou.Description)) t.Description = "No aescription available"; else t.Description = ou.Description; DbContext.GroupTemplates.Add(t); DbContext.SaveChanges(); return Content("Success", "text/html"); } catch (Exception ex) { AnvilExceptionCollector ec = new AnvilExceptionCollector(ex); return Content(ec.ToUL(), "text/html"); } }
public bool IsMemberOf(LcpsAdsGroup g) { foreach (string gdn in DirectoryEntry.Properties["memberOf"]) { if (gdn.ToLower() == g.DistinguishedName.ToLower()) return true; } return false; }
public LcpsAdsGroup[] GetGroupMembership() { List<LcpsAdsGroup> l = new List<LcpsAdsGroup>(); var groups = this.DirectoryEntry.Properties["memberOf"].Value; if (groups == null) return l.ToArray(); if (groups.GetType() == typeof(string)) { string p = "LDAP://" + DefaultApp.LDAPDomainFQN + "/" + (string)groups; LcpsAdsGroup g = new LcpsAdsGroup(p); l.Add(g); } else { ICollection gc = groups as ICollection; foreach (string g in gc) { string p = "LDAP://" + DefaultApp.LDAPDomainFQN + "/" + g; LcpsAdsGroup grp = new LcpsAdsGroup(p); l.Add(grp); } } return l.ToArray(); }