public void RemoveMember(string memberName) { var member = DirectoryServices.GetObject(memberName, AD_SearchScope.Subtree) as AD_Member; if (member == null) { throw new Exception(); } this.RemoveMember(member); }
public bool IsMemberOf(string groupName, out AD_Group group) { var tempGroup = DirectoryServices.GetObject(groupName, AD_SearchScope.Subtree) as AD_Group; if (tempGroup == null) { throw new Exception(); //TODO: throw custom exception } List <string> groupsChecked = new List <string>(); return(IsInGroupsMemberOf(this.Name, tempGroup, ref groupsChecked, out group)); }
public AD_Member[] GetMembers() { var results = new List <AD_Member>(); PropertyValueCollection colPropertyValues; using (var entry = new DirectoryEntry(this.Path)) { colPropertyValues = entry.Properties["member"]; } foreach (string memberPath in colPropertyValues) { AD_Member member; using (var memberEntry = new DirectoryEntry("LDAP://" + memberPath)) { member = (AD_Member)DirectoryServices.ObjectFactory(memberEntry); } results.Add(member); } return(results.ToArray()); }
public AD_Group[] GetMemberOf() { var results = new List <AD_Group>(); PropertyValueCollection colPropertyValues; using (var entry = new DirectoryEntry(this.Path)) { colPropertyValues = entry.Properties["memberOf"]; } foreach (string groupPath in colPropertyValues) { AD_Group group; using (var groupEntry = new DirectoryEntry("LDAP://" + groupPath)) { group = (AD_Group)DirectoryServices.ObjectFactory(groupEntry); } results.Add(group); } return(results.ToArray()); }
public void CreateObject(string name, AD_ObjectClass oClass) { DirectoryServices.CreateObject(this.Path, name, oClass); }
public AD_Object GetObject(string name) { return(DirectoryServices.GetObject(this.Path, name)); }
public AD_Object[] GetObjects(AD_ObjectClass oClass = AD_ObjectClass.All, AD_SearchScope scope = AD_SearchScope.Base) { return(DirectoryServices.GetObjects(this.Path, oClass, scope)); }