Beispiel #1
0
        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);
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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());
        }
Beispiel #4
0
        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());
        }
Beispiel #5
0
 public void CreateObject(string name, AD_ObjectClass oClass)
 {
     DirectoryServices.CreateObject(this.Path, name, oClass);
 }
Beispiel #6
0
 public AD_Object GetObject(string name)
 {
     return(DirectoryServices.GetObject(this.Path, name));
 }
Beispiel #7
0
 public AD_Object[] GetObjects(AD_ObjectClass oClass = AD_ObjectClass.All, AD_SearchScope scope = AD_SearchScope.Base)
 {
     return(DirectoryServices.GetObjects(this.Path, oClass, scope));
 }