Ejemplo n.º 1
0
        public Directory(IConnectionSettings connectionSettings, IDirectorySearcherOptions directorySearcherOptions)
        {
            if(connectionSettings == null)
                throw new ArgumentNullException("connectionSettings");

            this._connectionSettings = connectionSettings;
            this._directorySearcherOptions = directorySearcherOptions;

            string hostUrl = connectionSettings.Scheme.ToString() + "://" + connectionSettings.Host;
            if(connectionSettings.Port != null)
                hostUrl += ":" + connectionSettings.Port.Value.ToString(CultureInfo.InvariantCulture);
            if(!hostUrl.EndsWith("/", StringComparison.Ordinal))
                hostUrl += "/";

            this._hostUrl = hostUrl;
            this._rootPath = hostUrl + connectionSettings.DistinguishedName;
        }
Ejemplo n.º 2
0
 public virtual IEnumerable<ISearchResult> FindAll(string filter, IDirectorySearcherOptions directorySearcherOptions)
 {
     return this.FindAll(null, new ValueContainer<string>(filter), null, null, new ValueContainer<IDirectorySearcherOptions>(directorySearcherOptions));
 }
Ejemplo n.º 3
0
 public virtual IEnumerable<ISearchResult> FindAll(IDirectoryEntry searchRoot, IDirectorySearcherOptions directorySearcherOptions)
 {
     return this.FindAll(new ValueContainer<IDirectoryEntry>(searchRoot), null, null, null, new ValueContainer<IDirectorySearcherOptions>(directorySearcherOptions));
 }
Ejemplo n.º 4
0
        protected internal virtual void SetDirectorySearcherOptions(DirectorySearcher directorySearcher, IDirectorySearcherOptions directorySearcherOptions, ValueContainer<string> filter, ValueContainer<IEnumerable<string>> propertiesToLoad, ValueContainer<SearchScope> scope)
        {
            if(directorySearcher == null)
                throw new ArgumentNullException("directorySearcher");

            if(directorySearcherOptions == null)
                return;

            if(filter == null && directorySearcherOptions.Filter != null)
                directorySearcher.Filter = directorySearcherOptions.Filter.Value;

            if(propertiesToLoad == null && directorySearcherOptions.PropertiesToLoad != null)
            {
                directorySearcher.PropertiesToLoad.Clear();

                foreach(string propertyToLoad in directorySearcherOptions.PropertiesToLoad.Value ?? new string[0])
                {
                    directorySearcher.PropertiesToLoad.Add(propertyToLoad);
                }
            }

            if(scope == null && directorySearcherOptions.SearchScope.HasValue)
                directorySearcher.SearchScope = directorySearcherOptions.SearchScope.Value;

            if(directorySearcherOptions.Asynchronous.HasValue)
                directorySearcher.Asynchronous = directorySearcherOptions.Asynchronous.Value;

            if(directorySearcherOptions.AttributeScopeQuery != null)
                directorySearcher.AttributeScopeQuery = directorySearcherOptions.AttributeScopeQuery.Value;

            if(directorySearcherOptions.CacheResults.HasValue)
                directorySearcher.CacheResults = directorySearcherOptions.CacheResults.Value;

            if(directorySearcherOptions.ClientTimeout.HasValue)
                directorySearcher.ClientTimeout = directorySearcherOptions.ClientTimeout.Value;

            if(directorySearcherOptions.DereferenceAlias.HasValue)
                directorySearcher.DerefAlias = directorySearcherOptions.DereferenceAlias.Value;

            if(directorySearcherOptions.DirectorySynchronization != null)
                directorySearcher.DirectorySynchronization = directorySearcherOptions.DirectorySynchronization.Value;

            if(directorySearcherOptions.ExtendedDistinguishedName.HasValue)
                directorySearcher.ExtendedDN = directorySearcherOptions.ExtendedDistinguishedName.Value;

            if(directorySearcherOptions.PageSize.HasValue)
                directorySearcher.PageSize = directorySearcherOptions.PageSize.Value;

            if(directorySearcherOptions.PropertyNamesOnly.HasValue)
                directorySearcher.PropertyNamesOnly = directorySearcherOptions.PropertyNamesOnly.Value;

            if(directorySearcherOptions.ReferralChasing.HasValue)
                directorySearcher.ReferralChasing = directorySearcherOptions.ReferralChasing.Value;

            if(directorySearcherOptions.SecurityMasks.HasValue)
                directorySearcher.SecurityMasks = directorySearcherOptions.SecurityMasks.Value;

            if(directorySearcherOptions.ServerPageTimeLimit.HasValue)
                directorySearcher.ServerPageTimeLimit = directorySearcherOptions.ServerPageTimeLimit.Value;

            if(directorySearcherOptions.ServerTimeLimit.HasValue)
                directorySearcher.ServerTimeLimit = directorySearcherOptions.ServerTimeLimit.Value;

            if(directorySearcherOptions.SizeLimit.HasValue)
                directorySearcher.SizeLimit = directorySearcherOptions.SizeLimit.Value;

            if(directorySearcherOptions.Sort != null)
                directorySearcher.Sort = directorySearcherOptions.Sort.Value;

            if(directorySearcherOptions.Tombstone.HasValue)
                directorySearcher.Tombstone = directorySearcherOptions.Tombstone.Value;

            if(directorySearcherOptions.VirtualListView != null)
                directorySearcher.VirtualListView = directorySearcherOptions.VirtualListView.Value;
        }
Ejemplo n.º 5
0
 public virtual ISearchResult FindOne(IDirectoryEntry searchRoot, string filter, IEnumerable<string> propertiesToLoad, SearchScope scope, IDirectorySearcherOptions directorySearcherOptions)
 {
     return this.FindOne(new ValueContainer<IDirectoryEntry>(searchRoot), new ValueContainer<string>(filter), new ValueContainer<IEnumerable<string>>(propertiesToLoad), new ValueContainer<SearchScope>(scope), new ValueContainer<IDirectorySearcherOptions>(directorySearcherOptions));
 }
Ejemplo n.º 6
0
 public virtual ISearchResult FindOne(string filter, IEnumerable<string> propertiesToLoad, IDirectorySearcherOptions directorySearcherOptions)
 {
     return this.FindOne(null, new ValueContainer<string>(filter), new ValueContainer<IEnumerable<string>>(propertiesToLoad), null, new ValueContainer<IDirectorySearcherOptions>(directorySearcherOptions));
 }
Ejemplo n.º 7
0
 public virtual ISearchResult FindOne(IDirectoryEntry searchRoot, string filter, IDirectorySearcherOptions directorySearcherOptions)
 {
     return this.FindOne(new ValueContainer<IDirectoryEntry>(searchRoot), new ValueContainer<string>(filter), null, null, new ValueContainer<IDirectorySearcherOptions>(directorySearcherOptions));
 }
Ejemplo n.º 8
0
 public virtual ISearchResult FindOne(IDirectorySearcherOptions directorySearcherOptions)
 {
     return this.FindOne(null, null, null, null, new ValueContainer<IDirectorySearcherOptions>(directorySearcherOptions));
 }
Ejemplo n.º 9
0
 public virtual IEnumerable<ISearchResult> FindAll(string filter, IEnumerable<string> propertiesToLoad, SearchScope scope, IDirectorySearcherOptions directorySearcherOptions)
 {
     return this.FindAll(null, new ValueContainer<string>(filter), new ValueContainer<IEnumerable<string>>(propertiesToLoad), new ValueContainer<SearchScope>(scope), new ValueContainer<IDirectorySearcherOptions>(directorySearcherOptions));
 }
Ejemplo n.º 10
0
 public virtual IEnumerable<ISearchResult> FindAll(IDirectoryEntry searchRoot, string filter, IEnumerable<string> propertiesToLoad, IDirectorySearcherOptions directorySearcherOptions)
 {
     return this.FindAll(new ValueContainer<IDirectoryEntry>(searchRoot), new ValueContainer<string>(filter), new ValueContainer<IEnumerable<string>>(propertiesToLoad), null, new ValueContainer<IDirectorySearcherOptions>(directorySearcherOptions));
 }