예제 #1
0
        public static DirectoryEntryObject GetComputer(string identity, bool getAccessRules, bool getObjectProperties, bool loadSchema)
        {
            DirectoryEntryObject co = null;

            DirectoryEntry computer = GetDirectoryEntry(identity, AdObjectType.Computer.ToString());

            if (computer != null)
            {
                co = new DirectoryEntryObject(computer, loadSchema, getAccessRules, getObjectProperties);
            }

            return(co);
        }
        public static DirectoryEntryObject GetOrganizationalUnit(string identity, bool getAccessRules, bool getObjectProperties, bool loadSchema)
        {
            DirectoryEntryObject ouo = null;

            DirectoryEntry orgUnit = GetDirectoryEntry(identity, AdObjectType.OrganizationalUnit.ToString());

            if (orgUnit != null)
            {
                ouo = new DirectoryEntryObject(orgUnit, loadSchema, getAccessRules, getObjectProperties);
            }

            return(ouo);
        }
예제 #3
0
        public void SetPropertiesFromDirectoryEntry(DirectoryEntry de, bool loadSchema, bool getAccessRules, bool getObjectProperties, bool getParent)
        {
            if (de == null)
            {
                return;
            }

            Guid       = de.Guid;
            Name       = de.Name;
            NativeGuid = de.NativeGuid;
            if (getParent)
            {
                Parent = new DirectoryEntryObject(de.Parent, false, false, false, false);
            }

            if (de.Properties != null && getObjectProperties)
            {
                Properties = new SerializableDictionary <string, List <string> >();
                IDictionaryEnumerator ide = de.Properties.GetEnumerator();
                while (ide.MoveNext())
                {
                    List <string> propValues = DirectoryServices.GetPropertyValues(ide.Key.ToString(), ide.Value);
                    Properties.Add(ide.Key.ToString(), propValues);
                }
            }

            Path            = de.Path;
            SchemaClassName = de.SchemaClassName;
            if (loadSchema)
            {
                SchemaEntry = new DirectoryEntryObject(de.SchemaEntry, false, false, false);
            }
            UsePropertyCache = de.UsePropertyCache;
            Username         = de.Username;

            if (getAccessRules)
            {
                AccessRules = DirectoryServices.GetAccessRules(de);
            }
        }