コード例 #1
0
        private SearchResultEntryCollection DirSyncQuery(ref SearchRequestExtender reqStore)
        {
            SearchResultEntryCollection ret = null;

            try
            {
                SearchResponse sresponse = (SearchResponse)base.Connection.SendRequest(reqStore.Request);

                DirectoryControl dscontrol = GetControl(sresponse.Controls, reqStore.DirSyncControl.Type);

                reqStore.UpdateDirSyncCookie(dscontrol);

                ret = sresponse.Entries;
            }

            catch (LdapException ldapEx)
            {
                reqStore.HasError = true;
                reqStore.ErrorMSG = ldapEx.Message;

                return(null);
            }

            catch (Exception ex)
            {
                reqStore.HasError = true;
                reqStore.ErrorMSG = ex.Message;

                return(null);
            }

            return(ret);
        }
コード例 #2
0
ファイル: RequestHandler.cs プロジェクト: vossjannik/ldap4net
        private static Native.Native.LdapControl ToLdapControl(DirectoryControl sourceCtrl)
        {
            var ctrl = new Native.Native.LdapControl
            {
                // Get the control type.
                ldctl_oid = Encoder.Instance.StringToPtr(sourceCtrl.Type),

                // Get the control cricality.
                ldctl_iscritical = sourceCtrl.IsCritical
            };

            // Get the control value.
            var byteControlValue = sourceCtrl.GetValue();

            if (byteControlValue == null || byteControlValue.Length == 0)
            {
                // Treat the control value as null.
                ctrl.ldctl_value = new Native.Native.berval
                {
                    bv_len = 0,
                    bv_val = IntPtr.Zero
                };
            }
            else
            {
                ctrl.ldctl_value = new Native.Native.berval
                {
                    bv_len = byteControlValue.Length,
                    bv_val = Marshal.AllocHGlobal(byteControlValue.Length)
                };
                Marshal.Copy(byteControlValue, 0, ctrl.ldctl_value.bv_val, ctrl.ldctl_value.bv_len);
            }
            return(ctrl);
        }
コード例 #3
0
        private void SetPassword(string username, string newPassword)
        {
            var distinguishedName = string.Format(@"CN={0},{1}", username, _config.DistinguishedName);

            Logger.Info("Setting password for user: \"{0}\"", username);
            Logger.Info("Distinguished name: \"{0}\"", distinguishedName);

            // the 'unicodePWD' attribute is used to handle pwd handling requests
            const string attribute = "unicodePwd";

            if (!String.IsNullOrEmpty(newPassword))
            {
                // do we have a pwd to set -> set pwd
                var directoryAttributeModificationReplace = new DirectoryAttributeModification
                {
                    Name      = attribute,
                    Operation = DirectoryAttributeOperation.Replace
                };

                directoryAttributeModificationReplace.Add(BuildBytePwd(newPassword));

                var damList       = new[] { directoryAttributeModificationReplace };
                var modifyRequest = new ModifyRequest(distinguishedName, damList);

                // Should we utilize pwd history on the pwd reset?
                var value      = BerConverter.Encode("{i}", new object[] { 0x1 });
                var pwdHistory = new DirectoryControl(LdapServerPolicyHintsOid, value, false, true);

                modifyRequest.Controls.Add(pwdHistory);

                var response = _connection.SendRequest(modifyRequest);

                // TODO: handle bad response.
            }
        }
コード例 #4
0
        public virtual Dictionary <string, DirectoryAttribute> ReadObjectAttribute(string absolutePath, bool supportDeleted, params string[] attributes)
        {
            Dictionary <string, DirectoryAttribute> dictionary = new Dictionary <string, DirectoryAttribute>();

            try
            {
                SearchRequest searchRequest = new SearchRequest(absolutePath, Schema.Query.QueryAll, SearchScope.Base, attributes);
                if (supportDeleted)
                {
                    DirectoryControl control = new DirectoryControl("1.2.840.113556.1.4.417", null, true, true);
                    searchRequest.Controls.Add(control);
                }
                SearchResponse searchResponse = (SearchResponse)this.SendRequest(searchRequest);
                if (searchResponse.Entries.Count > 0)
                {
                    foreach (object obj in searchResponse.Entries[0].Attributes.Values)
                    {
                        DirectoryAttribute directoryAttribute = (DirectoryAttribute)obj;
                        dictionary.Add(directoryAttribute.Name, directoryAttribute);
                    }
                }
            }
            catch (ExDirectoryException ex)
            {
                if (ex.ResultCode != ResultCode.NoSuchObject)
                {
                    throw;
                }
            }
            return(dictionary);
        }
コード例 #5
0
        public void PageCookie(int pageSize)
        {
            FirstPagingRun = true;

            LastPageSize = pageSize;

            byte[] cvalue = BerConverter.Encode("{io}", new object[] { pageSize, PagingCookie });

            DirectoryControl dcpage = new DirectoryControl("1.2.840.113556.1.4.319", cvalue, true, true);

            if (PagingCookie != null)
            {
                PageControl = new PageResultRequestControl(PagingCookie);
            }

            else if (Scope != SearchScope.Base)
            {
                PageControl = new PageResultRequestControl(pageSize);
            }

            if (PageControl != null)
            {
                PageCount = 0;

                Request.Controls.Add(PageControl);

                DoPaging = true;
            }
        }
コード例 #6
0
ファイル: TestDirectory.cs プロジェクト: tgiqfe/PSFile
        /// <summary>
        /// Accessチェック
        /// </summary>
        private void CheckAccess()
        {
            string tempAccess = new DirectorySummary(DirectoryPath, false, true, true, true, true, true).Access;

            if (Access == string.Empty)
            {
                retValue = string.IsNullOrEmpty(tempAccess);
                if (!retValue)
                {
                    Console.Error.WriteLine("指定のアクセス権無し: \"{0}\" / \"{1}\"", Access, tempAccess);
                }
            }
            else if (TestMode == Item.CONTAIN)
            {
                //string tempAccess = new DirectorySummary(Path, false, true, true, true, true, true).Access;
                string[] tempAccessArray = tempAccess.Split('/');
                foreach (string accessString in Access.Split('/'))
                {
                    retValue = tempAccessArray.Any(x => DirectoryControl.IsMatchAccess(x, accessString));
                    if (!retValue)
                    {
                        Console.Error.WriteLine("指定のアクセス権無し: {0} / {1}", Access, tempAccess);
                        break;
                    }
                }
            }
            else
            {
                //string tempAccess = new DirectorySummary(Path, false, true, true, true, true, true).Access;
                List <string> accessListA = new List <string>();
                accessListA.AddRange(tempAccess.Split('/'));

                List <string> accessListB = new List <string>();
                accessListB.AddRange(Access.Split('/'));

                if (accessListA.Count == accessListB.Count)
                {
                    for (int i = accessListA.Count - 1; i >= 0; i--)
                    {
                        string matchString =
                            accessListB.FirstOrDefault(x => DirectoryControl.IsMatchAccess(x, accessListA[i]));
                        if (matchString != null)
                        {
                            accessListB.Remove(matchString);
                        }
                    }
                    retValue = accessListB.Count == 0;
                }
                else
                {
                    retValue = false;
                }

                if (!retValue)
                {
                    Console.Error.WriteLine("アクセス権不一致: {0} / {1}", Access, tempAccess);
                }
            }
        }
コード例 #7
0
        public void AddRange_NullObjectInValues_ThrowsArgumentException()
        {
            DirectoryControl[] controls = new DirectoryControl[] { new AsqRequestControl(), null, new AsqRequestControl() };
            var collection = new DirectoryControlCollection();

            AssertExtensions.Throws <ArgumentException>("controls", () => collection.AddRange(controls));
            Assert.Equal(0, collection.Count);
        }
コード例 #8
0
        public void ServerSide_Set_GetReturnsExpected()
        {
            var control = new DirectoryControl("Type", null, true, false);

            Assert.False(control.ServerSide);

            control.ServerSide = true;
            Assert.True(control.ServerSide);
        }
コード例 #9
0
        public void IsCritical_Set_GetReturnsExpected()
        {
            var control = new DirectoryControl("Type", null, false, true);

            Assert.False(control.IsCritical);

            control.IsCritical = true;
            Assert.True(control.IsCritical);
        }
コード例 #10
0
ファイル: LoginedPage.xaml.cs プロジェクト: sd05031/SEproject
        private void showDirectory(object sender, EventArgs e)
        {
            DirectoryControl DC = new DirectoryControl(SC);

            Navigation.PushAsync(new DirectoryPage
            {
                BindingContext = DC
            });
        }
コード例 #11
0
        private void RefreshSortControlWithDefaultLCID(DirectoryRequest request)
        {
            DirectoryControl value = this.FindControlInCollection(this.DirectoryControls, typeof(SortRequestControl));

            this.DirectoryControls.Remove(value);
            this.lcid = LcidMapper.DefaultLcid;
            this.AddSortControl();
            request.Controls.Clear();
            request.Controls.AddRange(this.DirectoryControls);
        }
コード例 #12
0
        public void AddRange_ValidControls_AddsToCollection()
        {
            DirectoryControl[] controls = new DirectoryControl[] { new AsqRequestControl(), new AsqRequestControl() };

            var collection = new DirectoryControlCollection();

            collection.AddRange(controls);

            Assert.Equal(controls, collection.Cast <DirectoryControl>());
        }
        public void TestUnavailableNonCriticalExtension()
        {
            using LdapConnection connection = GetConnection();

            var searchRequest = new SearchRequest(LdapConfiguration.Configuration.SearchDn, "(objectClass=*)", SearchScope.OneLevel);
            var control       = new DirectoryControl("==invalid-control==", value: null, isCritical: false, serverSide: true);

            searchRequest.Controls.Add(control);
            _ = (SearchResponse)connection.SendRequest(searchRequest);
            // Does not throw
        }
コード例 #14
0
        public void Ctor_Type_Value_IsCritical_ServerSide(string type, byte[] value, bool isCritical, bool serverSide)
        {
            var control = new DirectoryControl(type, value, isCritical, serverSide);

            Assert.Equal(type, control.Type);
            Assert.Equal(isCritical, control.IsCritical);
            Assert.Equal(serverSide, control.ServerSide);

            byte[] controlValue = control.GetValue();
            Assert.NotSame(controlValue, value);
            Assert.Equal(value ?? Array.Empty <byte>(), controlValue);
        }
コード例 #15
0
 private DirectoryControl FindControlInCollection(IEnumerable controls, Type controlType)
 {
     foreach (object obj in controls)
     {
         DirectoryControl directoryControl = (DirectoryControl)obj;
         if (directoryControl.GetType().Equals(controlType))
         {
             return(directoryControl);
         }
     }
     return(null);
 }
コード例 #16
0
        public void CopyTo_MultipleTypes_Success()
        {
            DirectoryControl[] array = new DirectoryControl[3];
            var control = new AsqRequestControl("name");

            var collection = new DirectoryControlCollection {
                control
            };

            collection.CopyTo(array, 1);
            Assert.Equal(new DirectoryControl[] { null, control, null }, array);
        }
コード例 #17
0
        private DirectoryControl GetControl(DirectoryControl[] controls, string OID)
        {
            DirectoryControl dcret = null;

            try
            { dcret = controls.ToList().Where(d => d.Type == OID).FirstOrDefault(); }

            catch (Exception ex)
            { ex.ToDummy(); }

            return(dcret);
        }
コード例 #18
0
        public static void Deserialize(XmlDictionaryReader reader, out IList <DirectoryControl> controls, bool mustBePresent, bool fullChecks)
        {
            string str  = null;
            string str1 = null;
            bool   flag;

            byte[] numArray = null;
            controls = new List <DirectoryControl>();
            if (mustBePresent || reader.IsStartElement("controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
            {
                reader.ReadFullStartElement("controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory");
                while (reader.IsStartElement("control", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
                {
                    string attribute  = reader.GetAttribute("type");
                    string attribute1 = reader.GetAttribute("criticality");
                    reader.Read();
                    if (!reader.IsStartElement("controlValue", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
                    {
                        numArray = null;
                    }
                    else
                    {
                        string attribute2 = reader.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance");
                        if (attribute2 != null)
                        {
                            XmlUtility.SplitPrefix(attribute2, out str, out str1);
                            numArray = reader.ReadElementContentAsBase64();
                        }
                        else
                        {
                            throw new ArgumentException();
                        }
                    }
                    if (!string.Equals("true", attribute1))
                    {
                        flag = false;
                    }
                    else
                    {
                        flag = true;
                    }
                    DirectoryControl directoryControl = new DirectoryControl(attribute, numArray, flag, true);
                    controls.Add(directoryControl);
                    reader.Read();
                }
                return;
            }
            else
            {
                return;
            }
        }
コード例 #19
0
        protected override void OnAppearing()
        {
            datas           = (Object[])BindingContext;
            data            = new string[2];
            data[0]         = datas[0] as string;
            data[1]         = datas[1] as string;
            PathLabel.Text  = data[0];
            FNameLabel.Text = data[1];
            DC = datas[2] as DirectoryControl;

            filecheck();
            base.OnAppearing();
        }
        public void TestUnavailableCriticalExtension()
        {
            using LdapConnection connection = GetConnection();

            DirectoryOperationException ex = Assert.Throws <DirectoryOperationException>(() =>
            {
                var searchRequest = new SearchRequest(LdapConfiguration.Configuration.SearchDn, "(objectClass=*)", SearchScope.OneLevel);
                var control       = new DirectoryControl("==invalid-control==", value: null, isCritical: true, serverSide: true);
                searchRequest.Controls.Add(control);
                _ = (SearchResponse)connection.SendRequest(searchRequest);
            });

            Assert.Equal(ResultCode.UnavailableCriticalExtension, ex.Response.ResultCode);
        }
コード例 #21
0
 internal static void AppendTo(this DirectoryControl control, StringBuilder sb)
 {
     if (control is PageResultRequestControl)
     {
         var pageControl = control as PageResultRequestControl;
         sb.AppendLine("Page Size: " + pageControl.PageSize);
         sb.AppendLine("Page Cookie Length: " + (pageControl.Cookie != null ? pageControl.Cookie.Length : 0));
         sb.AppendLine("Page Control Is Critical: " + control.IsCritical);
         sb.AppendLine("Page Control OID: " + control.Type);
     }
     if (control is VlvRequestControl)
     {
         var vlvControl = control as VlvRequestControl;
         sb.AppendLine("After Count: " + vlvControl.AfterCount);
         sb.AppendLine("Before Count: " + vlvControl.BeforeCount);
         sb.AppendLine("Offset: " + vlvControl.Offset);
         sb.AppendLine("Target: " + (vlvControl.Target == null || vlvControl.Target.Length == 0 ? "" : UTF8Encoding.UTF8.GetString(vlvControl.Target)));
         sb.AppendLine("Vlv Control Is Critical: " + control.IsCritical);
         sb.AppendLine("Vlv Control OID: " + control.Type);
     }
     else if (control is SortRequestControl)
     {
         var sortControl = control as SortRequestControl;
         var sortKey     = sortControl.SortKeys.FirstOrDefault();
         if (sortKey != null)
         {
             sb.AppendLine("Sort By: " + sortKey.AttributeName + " " + (sortKey.ReverseOrder ? "DESC" : "ASC"));
         }
         sb.AppendLine("Sort Control Is Critical: " + control.IsCritical);
         sb.AppendLine("Sort Control OID: " + control.Type);
     }
     else if (control is AsqRequestControl)
     {
         var asqControl = control as AsqRequestControl;
         sb.AppendLine("Attribute Scope: " + asqControl.AttributeName);
         sb.AppendLine("Attribute Scope Control Is Critical: " + control.IsCritical);
         sb.AppendLine("Attribute Scope Control OID: " + control.Type);
     }
     else
     {
         sb.AppendLine(control.GetType().Name + " Control");
         sb.AppendLine("Control Is Critical: " + control.IsCritical);
         sb.AppendLine("Control OID: " + control.Type);
     }
 }
コード例 #22
0
        public void UpdatePagingCookie(DirectoryControl dControl, int pageSize)
        {
            if (FirstPagingRun)
            {
                CurrentPageSize = pageSize;

                FirstPagingRun = false;
            }

            else if (pageSize > CurrentPageSize)
            {
                CurrentPageSize = pageSize;
            }


            Request.Controls.Remove(PageControl);

            MoreData = false;

            if (dControl != null)
            {
                PageResultResponseControl response = (PageResultResponseControl)dControl;

                PagingCookie = response.Cookie;
            }

            if ((PagingCookie != null) && (PagingCookie.Length != 0))
            {
                MoreData = true;
            }

            else
            {
                MoreData = false;
            }

            if (MoreData)
            {
                PageControl = new PageResultRequestControl(PagingCookie);

                PageControl.PageSize = pageSize;

                Request.Controls.Add(PageControl);
            }
        }
コード例 #23
0
        public void UpdateDirSyncCookie(DirectoryControl dControl)
        {
            Request.Controls.Remove(DirSyncControl);

            MoreData = false;

            DirSyncResponseControl response = null;

            if (dControl != null)
            {
                response = (DirSyncResponseControl)dControl;

                MoreData = response.MoreData;
            }

            if (MoreData)
            {
                QueryInfo.DirSyncCookie = response.Cookie;

                DirSyncCookie();
            }
        }
	public bool Contains(DirectoryControl value) {}
コード例 #25
0
 public void AddControl(DirectoryControl control)
 {
     this.UserControls.Add(control);
 }
	// Methods
	public int Add(DirectoryControl control) {}
コード例 #27
0
ファイル: NewDirectory.cs プロジェクト: tgiqfe/PSFile
        protected override void ProcessRecord()
        {
            if (Directory.Exists(DirectoryPath)) { return; }

            //  テスト自動生成
            _generator.DirectoryPath(DirectoryPath);

            Directory.CreateDirectory(DirectoryPath);

            DirectorySecurity security = null;

            //  Access設定
            if (!string.IsNullOrEmpty(Access))
            {
                if (security == null) { security = Directory.GetAccessControl(DirectoryPath); }

                //  テスト自動生成
                _generator.DirectoryAccess(DirectoryPath, Access, false);

                foreach (FileSystemAccessRule addRule in DirectoryControl.StringToAccessRules(Access))
                {
                    security.AddAccessRule(addRule);
                }
            }

            //  Owner設定
            if (!string.IsNullOrEmpty(Owner))
            {
                //  埋め込みのsubinacl.exeを展開
                string subinacl = EmbeddedResource.GetSubinacl(Item.APPLICATION_NAME);

                //  管理者実行確認
                Functions.CheckAdmin();

                //  テスト自動生成
                _generator.DirectoryOwner(DirectoryPath, Owner);

                using (Process proc = new Process())
                {
                    proc.StartInfo.FileName = subinacl;
                    proc.StartInfo.Arguments = $"/subdirectories \"{DirectoryPath}\" /setowner=\"{Owner}\"";
                    proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    proc.Start();
                    proc.WaitForExit();
                }
            }

            //  Inherited設定
            if (Inherited != Item.NONE)
            {
                if (security == null) { security = Directory.GetAccessControl(DirectoryPath); }

                //  テスト自動生成
                _generator.DirectoryInherited(DirectoryPath, Inherited == Item.ENABLE);

                switch (Inherited)
                {
                    case Item.ENABLE:
                        security.SetAccessRuleProtection(false, false);
                        break;
                    case Item.DISABLE:
                        security.SetAccessRuleProtection(true, true);
                        break;
                    case Item.REMOVE:
                        security.SetAccessRuleProtection(true, false);
                        break;
                }
            }

            if (security != null) { Directory.SetAccessControl(DirectoryPath, security); }

            //  作成日時
            if (CreationTime != null)
            {
                //  テスト自動生成
                _generator.DirectoryCreationTime(DirectoryPath, (DateTime)CreationTime);

                Directory.SetCreationTime(DirectoryPath, (DateTime)CreationTime);
            }

            //  更新一時
            if (LastWriteTime != null)
            {
                //  テスト自動生成
                _generator.DirectoryLastWriteTime(DirectoryPath, (DateTime)LastWriteTime);

                Directory.SetLastWriteTime(DirectoryPath, (DateTime)LastWriteTime);
            }

            //  フォルダー属性
            if (!string.IsNullOrEmpty(_Attributes))
            {
                //  テスト自動生成
                _generator.DirectoryAttributes(DirectoryPath, _Attributes, false);

                if (!_Attributes.Contains(Item.DIRECTORY))
                {
                    _Attributes += ", " + Item.DIRECTORY;
                }
                File.SetAttributes(DirectoryPath, (FileAttributes)Enum.Parse(typeof(FileAttributes), _Attributes));
            }

            WriteObject(new DirectorySummary(DirectoryPath, true));
        }
	public void AddRange(DirectoryControl[] controls) {}
コード例 #29
0
        protected SearchResultEntryCollection GetNextResultCollection(Type controlType, out DirectoryControl responseControl)
        {
            SearchRequest searchRequest = new SearchRequest(null, this.ldapFilter, (SearchScope)this.scope, this.ldapAttributes);

            searchRequest.Controls.AddRange(this.directoryControls);
            searchRequest.SizeLimit = this.SizeLimit;
            if (this.session.ServerTimeout != null)
            {
                searchRequest.TimeLimit = this.session.ServerTimeout.Value;
            }
            SearchResponse searchResponse = null;

            responseControl = null;
            RetryManager retryManager = new RetryManager();
            ADObjectId   adobjectId   = this.rootId;
            bool         flag         = !this.session.SessionSettings.IncludeSoftDeletedObjects && !this.session.SessionSettings.IncludeInactiveMailbox && this.session.EnforceContainerizedScoping;

            for (;;)
            {
                PooledLdapConnection readConnection = this.session.GetReadConnection(this.preferredServerName, null, ref adobjectId, this.ScopeDeterminingObject);
                Guid serviceProviderRequestId       = Guid.Empty;
                try
                {
                    try
                    {
                        if (this.useNullRoot)
                        {
                            searchRequest.DistinguishedName = null;
                        }
                        else
                        {
                            searchRequest.DistinguishedName = adobjectId.ToDNString();
                            if (flag && searchRequest.Scope == SearchScope.Subtree)
                            {
                                ADObjectId domainId = adobjectId.DomainId;
                                if (domainId != null)
                                {
                                    ADObjectId childId = domainId.GetChildId("OU", "Microsoft Exchange Hosted Organizations");
                                    ADObjectId parent  = adobjectId.Parent;
                                    if (childId != null && parent != null && ADObjectId.Equals(childId, parent))
                                    {
                                        searchRequest.Scope = SearchScope.OneLevel;
                                    }
                                }
                            }
                        }
                        if (TopologyProvider.IsAdamTopology() && string.IsNullOrEmpty(searchRequest.DistinguishedName))
                        {
                            searchRequest.Controls.Add(new SearchOptionsControl(SearchOption.PhantomRoot));
                        }
                        ExTraceGlobals.ADFindTracer.TraceDebug((long)this.GetHashCode(), "ADGenericReader::GetNextResultCollection({0}) using {1} - LDAP search from {2}, scope {3}, filter {4}", new object[]
                        {
                            controlType.Name,
                            readConnection.ADServerInfo.FqdnPlusPort,
                            searchRequest.DistinguishedName,
                            (int)searchRequest.Scope,
                            searchRequest.Filter
                        });
                        serviceProviderRequestId = Trace.TraceCasStart(CasTraceEventType.ActiveDirectory);
                        searchResponse           = (SearchResponse)readConnection.SendRequest(searchRequest, LdapOperation.Search, null, this.session.ActivityScope, this.session.CallerInfo);
                        this.preferredServerName = readConnection.ServerName;
                        this.session.UpdateServerSettings(readConnection);
                        break;
                    }
                    catch (DirectoryException de)
                    {
                        if (this.customExceptionHandler != null)
                        {
                            this.customExceptionHandler(de);
                        }
                        if (readConnection.IsResultCode(de, ResultCode.NoSuchObject))
                        {
                            ExTraceGlobals.ADFindTracer.TraceWarning <string, object>((long)this.GetHashCode(), "NoSuchObject caught when searching from {0} with filter {1}", searchRequest.DistinguishedName, searchRequest.Filter);
                            return(null);
                        }
                        if (readConnection.IsResultCode(de, ResultCode.VirtualListViewError) && this.lcid != LcidMapper.DefaultLcid)
                        {
                            ExTraceGlobals.ADFindTracer.TraceWarning <int, int>((long)this.GetHashCode(), "VirtualListView error caught when performing a VLV lookup using LCID 0x{0:X}. Falling back to US English 0x{1:X}", this.lcid, LcidMapper.DefaultLcid);
                            this.RefreshSortControlWithDefaultLCID(searchRequest);
                        }
                        else
                        {
                            retryManager.Tried(readConnection.ServerName);
                            this.session.AnalyzeDirectoryError(readConnection, searchRequest, de, retryManager.TotalRetries, retryManager[readConnection.ServerName]);
                        }
                    }
                    continue;
                }
                finally
                {
                    bool isSnapshotInProgress = PerformanceContext.Current.IsSnapshotInProgress;
                    bool flag2 = ETWTrace.ShouldTraceCasStop(serviceProviderRequestId);
                    if (isSnapshotInProgress || flag2)
                    {
                        string text = string.Format(CultureInfo.InvariantCulture, "scope: {0}, filter: {1}", new object[]
                        {
                            searchRequest.Scope,
                            searchRequest.Filter
                        });
                        if (isSnapshotInProgress)
                        {
                            PerformanceContext.Current.AppendToOperations(text);
                        }
                        if (flag2)
                        {
                            Trace.TraceCasStop(CasTraceEventType.ActiveDirectory, serviceProviderRequestId, 0, 0, readConnection.ADServerInfo.FqdnPlusPort, searchRequest.DistinguishedName, "ADGenericReader::GetNextResultCollection", text, string.Empty);
                        }
                    }
                    readConnection.ReturnToPool();
                }
                break;
            }
            responseControl = this.FindControlInCollection(searchResponse.Controls, controlType);
            return(searchResponse.Entries);
        }
コード例 #30
0
        // Token: 0x060006F4 RID: 1780 RVA: 0x00025650 File Offset: 0x00023850
        protected override SearchResultEntryCollection GetNextResultCollection()
        {
            if (base.Session.NetworkCredential == null)
            {
                this.vlvRequestControl.ContextId = base.Cookie;
            }
            this.vlvRequestControl.Offset = this.offSet;
            if (this.searchForward)
            {
                this.vlvRequestControl.BeforeCount = 0;
                this.vlvRequestControl.AfterCount  = (this.includeBookmarkObject ? (base.PageSize - 1) : base.PageSize);
            }
            else
            {
                this.vlvRequestControl.BeforeCount = (this.includeBookmarkObject ? (base.PageSize - 1) : base.PageSize);
                this.vlvRequestControl.AfterCount  = 0;
            }
            DirectoryControl            directoryControl            = null;
            SearchResultEntryCollection searchResultEntryCollection = null;

            try
            {
                searchResultEntryCollection = base.GetNextResultCollection(typeof(VlvResponseControl), out directoryControl);
            }
            catch (ADInvalidHandleCookieException ex)
            {
                if (this.vlvRequestControl.ContextId == null || this.vlvRequestControl.ContextId.Length == 0)
                {
                    throw;
                }
                ExTraceGlobals.ADFindTracer.TraceDebug <string>((long)this.GetHashCode(), "ADVlvPagedReader::GetNextResultCollection encounter an exception \"{0}\". Clear the cookie and try again.", ex.Message);
                this.vlvRequestControl.ContextId = null;
                searchResultEntryCollection      = base.GetNextResultCollection(typeof(VlvResponseControl), out directoryControl);
            }
            ADProviderPerf.UpdateProcessCounter(Counter.ProcessRateVlv, UpdateType.Add, 1U);
            ADProviderPerf.UpdateDCCounter(base.PreferredServerName, Counter.DCRateVlv, UpdateType.Add, 1U);
            base.Cookie = ((directoryControl == null) ? null : ((VlvResponseControl)directoryControl).ContextId);
            if (!this.searchForward)
            {
                base.RetrievedAllData = new bool?(true);
            }
            if (directoryControl == null || searchResultEntryCollection.Count == 0)
            {
                base.RetrievedAllData = new bool?(true);
            }
            else
            {
                this.totalCount = ((VlvResponseControl)directoryControl).ContentCount;
                if (this.searchForward && base.PagesReturned == 0)
                {
                    this.offSet = ((VlvResponseControl)directoryControl).TargetPosition;
                    if (!this.includeBookmarkObject)
                    {
                        this.offSet++;
                    }
                }
                if (!this.searchForward)
                {
                    this.offSet = ((VlvResponseControl)directoryControl).TargetPosition - searchResultEntryCollection.Count + 1;
                }
                this.firstEntry = (string)searchResultEntryCollection[0].Attributes[ADRecipientSchema.DisplayName.LdapDisplayName].GetValues(typeof(string))[0];
                this.lastEntry  = (string)searchResultEntryCollection[searchResultEntryCollection.Count - 1].Attributes[ADRecipientSchema.DisplayName.LdapDisplayName].GetValues(typeof(string))[0];
                if (string.Compare(this.firstEntry, this.lastEntry, new CultureInfo(base.Lcid), CompareOptions.OrdinalIgnoreCase) == 0)
                {
                    base.RetrievedAllData = new bool?(true);
                }
                if (this.searchForward)
                {
                    this.vlvRequestControl.Target = Encoding.UTF8.GetBytes(this.lastEntry);
                }
                else
                {
                    this.vlvRequestControl.Target = Encoding.UTF8.GetBytes(this.firstEntry);
                }
            }
            return(searchResultEntryCollection);
        }
	public void Remove(DirectoryControl value) {}
コード例 #32
0
        private void PagedAsyncQueryCallBackPartial(IAsyncResult Result)
        {
            PartialResultsCollection pResults = null;

            SearchResultEntry[] temp = new SearchResultEntry[0];

            if (!Result.IsCompleted)
            {
                pResults = base.Connection.GetPartialResults(Result);

                if (pResults != null)
                {
                    temp = new SearchResultEntry[pResults.Count];

                    pResults.CopyTo(temp, 0);
                }
            }
            else
            {
                SearchResponse sresponse = null;

                try
                {
                    sresponse = (SearchResponse)base.AsyncConnection.EndSendRequest(Result);
                }

                catch (DirectoryOperationException direx)
                {
                    if (direx.Response != null)
                    {
                        if (direx.Response.ResultCode == ResultCode.SizeLimitExceeded)
                        {
                            if (ForestBase.CurrentRequestExtender.QueryInfo.AutoPage)
                            {
                                GlobalEventHandler.RaiseErrorOccured(String.Format("Non-PagedQuery: {0} - switched to PagedQuery", direx.Response.ResultCode.ToString()));

                                ForestBase.CurrentRequestExtender.AddMessage(String.Format("Non-PagedQuery: {0} - switched to PagedQuery", direx.Response.ResultCode.ToString()));

                                ForestBase.CurrentRequestExtender.PageCookie(((SearchResponse)direx.Response).Entries.Count);

                                ForestBase.CurrentRequestExtender.MoreData = true;

                                PagedAsyncQuery();
                            }
                        }
                    }
                }

                catch (Exception ex)
                { string x = ex.Message; }

                temp = new SearchResultEntry[sresponse.Entries.Count];

                sresponse.Entries.CopyTo(temp, 0);

                if (ForestBase.CurrentRequestExtender.RetreiveStatistics)
                {
                    DirectoryControl dcStats = GetControl(sresponse.Controls, SearchRequestExtender.STATISTCS_CONTROL_OID);

                    if (dcStats != null)
                    {
                        ForestBase.CurrentRequestExtender.Statistics.Add(new StatsData(dcStats.GetValue()));
                    }

                    else
                    {
                        GlobalEventHandler.RaiseErrorOccured("WARNING: No Query Statistics data returned");
                    }
                }

                DirectoryControl pageRespControl = GetControl(sresponse.Controls, ForestBase.CurrentRequestExtender.PageControl.Type);

                ForestBase.CurrentRequestExtender.UpdatePagingCookie(pageRespControl, sresponse.Entries.Count);


                base.AsyncCalls--;
                base.ParallelRuns--;
            }

            GlobalEventHandler.RaiseAsyncPartialResult(temp.ToList(), !ForestBase.CurrentRequestExtender.MoreData);

            if (!CancelToken)
            {
                if (ForestBase.CurrentRequestExtender.MoreData)
                {
                    PagedAsyncQuery();
                }

                else if (base.ParallelRuns < 1)
                {
                    GlobalEventHandler.RaiseParallelQueriesCompleted();
                }
            }

            else
            {
                GlobalEventHandler.RaiseParallelQueriesCompleted();
            }
        }
	public int IndexOf(DirectoryControl value) {}
	public void CopyTo(DirectoryControl[] array, int index) {}
コード例 #35
0
        private SearchResultEntryCollection PagedQuery(ref SearchRequestExtender reqStore)
        {
            SearchResultEntryCollection ret = null;

            SearchResponse sresponse = null;

            bool goon = false;

            try
            {
                if ((base.IsConnected == false) || (base.Connection == null))
                {
                    Connect(reqStore.DC, reqStore.ReferralChasing, connectionLess: reqStore.QueryInfo.RootDse);
                }

                sresponse = (SearchResponse)base.Connection.SendRequest(reqStore.Request);

                goon = true;
            }

            catch (LdapException ldapEx)
            {
                base.SetError(ldapEx.Message);

                reqStore.HasError = true;
                reqStore.ErrorMSG = ldapEx.Message;

                return(null);
            }

            catch (DirectoryOperationException direx)
            {
                if (direx.Response != null)
                {
                    if (direx.Response.ResultCode == ResultCode.SizeLimitExceeded)
                    {
                        if (reqStore.QueryInfo.AutoPage)
                        {
                            GlobalEventHandler.RaiseErrorOccured(String.Format("Non-PagedQuery: {0} - switched to PagedQuery", direx.Response.ResultCode.ToString()));

                            reqStore.AddMessage(String.Format("Non-PagedQuery: {0} - switched to PagedQuery", direx.Response.ResultCode.ToString()));

                            reqStore.PageCookie(((SearchResponse)direx.Response).Entries.Count);

                            reqStore.MoreData = true;
                        }

                        else
                        {
                            sresponse = (SearchResponse)direx.Response;

                            GlobalEventHandler.RaiseErrorOccured(String.Format("\tNon-PagedQuery: {0} - returned first {1} entries", direx.Response.ResultCode.ToString(), sresponse.Entries.Count));

                            reqStore.AddMessage(String.Format("Non-PagedQuery: {0} - returned first {1} entries", direx.Response.ResultCode.ToString(), sresponse.Entries.Count));
                        }

                        goon = true;
                    }

                    else if ((direx.Response.ResultCode == ResultCode.UnavailableCriticalExtension) &&
                             direx.Response.ErrorMessage.StartsWith("00002040") &&
                             (reqStore.PageControl != null) &&
                             (reqStore.ReferralChasing != ReferralChasingOptions.None))
                    {
                        reqStore.PageCount--;

                        string msg = "Multiple page cookies from referrals.";

                        msg = String.Format("{0} ({1})", msg, direx.Message);

                        if (direx.Response.ErrorMessage != null)
                        {
                            msg = String.Format("{0}: ({1})", msg, direx.Response.ErrorMessage);
                        }

                        base.SetError(msg);

                        reqStore.HasError = true;

                        reqStore.ErrorMSG = base.ErrorMSG;

                        //goon = true;
                    }

                    else
                    {
                        string msg = direx.Message;

                        if (direx.Response.ErrorMessage != null)
                        {
                            msg = String.Format("{0}: ({1})", msg, direx.Response.ErrorMessage);
                        }

                        base.SetError(msg);

                        reqStore.HasError = true;

                        reqStore.ErrorMSG = base.ErrorMSG;
                    }
                }

                else // if (!goon)
                {
                    base.SetError(direx.Message);

                    reqStore.HasError = true;
                    reqStore.ErrorMSG = base.ErrorMSG;
                }
            }

            catch (Exception ex)
            {
                base.SetError(ex.Message);

                reqStore.HasError = true;
                reqStore.ErrorMSG = ex.Message;

                return(null);
            }

            if (goon)
            {
                if (sresponse != null)
                {
                    if (reqStore.RetreiveStatistics)
                    {
                        DirectoryControl dcStats = GetControl(sresponse.Controls, SearchRequestExtender.STATISTCS_CONTROL_OID);

                        if (dcStats != null)
                        {
                            reqStore.Statistics.Add(new StatsData(dcStats.GetValue()));
                        }

                        else
                        {
                            GlobalEventHandler.RaiseErrorOccured("WARNING: No Query Statistics data returned");
                        }
                    }

                    if (reqStore.PageControl != null)
                    {
                        DirectoryControl pageRespControl = GetControl(sresponse.Controls, reqStore.PageControl.Type);

                        reqStore.UpdatePagingCookie(pageRespControl, sresponse.Entries.Count);
                    }

                    ret = sresponse.Entries;
                }
            }

            return(ret);
        }
コード例 #36
0
 // Token: 0x0600109A RID: 4250 RVA: 0x000501E8 File Offset: 0x0004E3E8
 public static SearchStatsControl FindSearchStatsControl(DirectoryRequest request)
 {
     DirectoryControl[] array = new DirectoryControl[request.Controls.Count];
     request.Controls.CopyTo(array, 0);
     return(SearchStatsControl.FindSearchStatsControl(array));
 }
	public void Insert(int index, DirectoryControl value) {}