Exemplo n.º 1
0
 internal ActiveDirectoryDataAccess(ActiveDirectoryObjectType activeDirectoryObjectType, object parameters, bool loadAllProperties)
 {
     _configuration             = RepositoryDbAccess.Configuration;
     _activeDirectoryObjectType = activeDirectoryObjectType;
     _parameters        = parameters;
     _loadAllProperties = loadAllProperties;
 }
Exemplo n.º 2
0
        public static ActiveDirectoryObject Create(string name, ActiveDirectoryObjectType activeDirectoryObjectType)
        {
            var role = new ActiveDirectoryObject
            {
                Id         = Guid.NewGuid(),
                Name       = name,
                ObjectType = activeDirectoryObjectType
            };

            return(role);
        }
Exemplo n.º 3
0
        private string GetSearchPattern(ActiveDirectoryObjectType objectType, Dictionary <string, object> parameters, bool checkAll)
        {
            var searchPattern = String.Empty;

            if (objectType == ActiveDirectoryObjectType.User)
            {
                searchPattern = "(&(objectClass=user){0})";
            }

            var parametersPattern = String.Empty;

            if (parameters != null)
            {
                parametersPattern = parameters.Aggregate(parametersPattern, (pattern, param) => pattern + String.Format("({0}={1})", param.Key, param.Value));
            }

            return(String.Format(searchPattern, !String.IsNullOrWhiteSpace(parametersPattern)
                                                ? String.Format("({0} {1})", checkAll ? "&" : "|", parametersPattern)
                                                : String.Empty));
        }
        internal static ActiveDirectoryObjectType GetActiveDirectoryObjectType(SearchResult searchResult)
        {
            ActiveDirectoryObjectType activeDirectoryObjectType = ActiveDirectoryObjectType.Unknow;

            if (searchResult != null)
            {
                var resultPropertyValueCollection = searchResult.Properties[AttributeNames.ObjectClass];
                for (int index = 0; index < resultPropertyValueCollection.Count; index++)
                {
                    switch (resultPropertyValueCollection[index].ToString())
                    {
                    case UserAttributeValues.User:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.User;
                        break;

                    case ContactAttributeValues.Contact:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.Contact;
                        break;

                    case ComputerAttributeValues.Computer:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.Computer;
                        break;

                    case ContainerAttributeValues.Container:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.Container;
                        break;

                    case GroupAttributeValues.Group:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.Group;
                        break;

                    case InetOrgPersonAttributeValues.InetOrgPerson:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.InetOrgPerson;
                        break;

                    case MSMQQueueAliasAttributeValues.MSMQQueueAlias:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.MSMQQueueAlias;
                        break;

                    case MsImaging_PSPsAttributeValues.MsImaging_PSPs:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.MsImaging_PSPs;
                        break;

                    case OrganizationalUnitAttributeValues.OrganizationalUnit:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.OrganizationalUnit;
                        break;

                    case PrinterAttributeValues.Printer:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.Printer;
                        break;

                    case SharedFolderAttributeValues.SharedFolder:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.SharedFolder;
                        break;

                    case DomainControllerAttributeValues.Domain:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.DomainController;
                        break;

                    case PasswordSettingsAttributeValues.MsDS_PasswordSettings:
                        activeDirectoryObjectType = ActiveDirectoryObjectType.PasswordSettings;
                        break;

                    default:
                        break;
                    }
                }
            }
            return(activeDirectoryObjectType);
        }
        private static ActiveDirectoryObject GetActiveDirectoryObject(SearchResult searchResult)
        {
            ActiveDirectoryObject     activeDirectoryObject;
            ActiveDirectoryObjectType activeDirectoryObjectType = GetActiveDirectoryObjectType(searchResult);

            switch (activeDirectoryObjectType)
            {
            case ActiveDirectoryObjectType.User:
                activeDirectoryObject = new User(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.Contact:
                activeDirectoryObject = new Contact(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.Computer:
                activeDirectoryObject = new Computer(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.Container:
                activeDirectoryObject = new Container(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.Group:
                activeDirectoryObject = new Group(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.InetOrgPerson:
                activeDirectoryObject = new InetOrgPerson(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.MSMQQueueAlias:
                activeDirectoryObject = new MSMQQueueAlias(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.MsImaging_PSPs:
                activeDirectoryObject = new MsImaging_PSPs(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.OrganizationalUnit:
                activeDirectoryObject = new OrganizationalUnit(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.Printer:
                activeDirectoryObject = new Printer(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.SharedFolder:
                activeDirectoryObject = new SharedFolder(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.DomainController:
                activeDirectoryObject = new DomainController(searchResult.GetDirectoryEntry());
                break;

            case ActiveDirectoryObjectType.PasswordSettings:
                activeDirectoryObject = new PasswordSettings(searchResult.GetDirectoryEntry());
                break;

            default:
                activeDirectoryObject = new UnknownObject(searchResult.GetDirectoryEntry());
                break;
            }
            return(activeDirectoryObject);
        }
 internal ActiveDirectoryDataAccess(ActiveDirectoryObjectType activeDirectoryObjectType, object parameters)
 {
     _activeDirectoryObjectType = activeDirectoryObjectType;
     _parameters = parameters;
 }
 internal ActiveDirectoryDataAccessQuery(ActiveDirectoryObjectType activeDirectoryObjectType)
 {
     _activeDirectoryObjectType = activeDirectoryObjectType;
 }