Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 5
0
 public void CreateObject(string name, AD_ObjectClass oClass)
 {
     DirectoryServices.CreateObject(this.Path, name, oClass);
 }
Ejemplo n.º 6
0
 public AD_Object GetObject(string name)
 {
     return(DirectoryServices.GetObject(this.Path, name));
 }
Ejemplo n.º 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));
 }