Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Activities / Role / DirectoryRedirect.cs / 1305376 / DirectoryRedirect.cs
#region Using directives using System; using System.Collections.Generic; using System.Text; using System.DirectoryServices; #endregion namespace System.Workflow.Activities { [Serializable] sealed internal class DirectoryRedirect : IDirectoryOperation { private String m_getPropertyName; private String m_searchPropertyName; private bool m_recursive; public DirectoryRedirect(String getPropertyName, String searchPropertyName) : this( getPropertyName, searchPropertyName, false ) { } public DirectoryRedirect(String getPropertyName, String searchPropertyName, bool recursive) { if (getPropertyName == null) throw new ArgumentNullException("getPropertyName"); if (searchPropertyName == null) throw new ArgumentNullException("searchPropertyName"); this.m_getPropertyName = getPropertyName; this.m_searchPropertyName = searchPropertyName; this.m_recursive = recursive; } public void GetResult(DirectoryEntry rootEntry, DirectoryEntry currentEntry, Listresponse) { if (rootEntry == null) throw new ArgumentNullException("rootEntry"); if (currentEntry == null) throw new ArgumentNullException("currentEntry"); if (response == null) throw new ArgumentNullException("response"); if (!this.m_recursive) { using (DirectorySearcher searcher = CreateSearcher(rootEntry, currentEntry)) { foreach (SearchResult result in searcher.FindAll()) { response.Add(result.GetDirectoryEntry()); } } } else { Dictionary dResponse = new Dictionary (); Stack stack = new Stack (); stack.Push(currentEntry); while (stack.Count != 0) { DirectoryEntry currentTop = stack.Pop(); using (DirectorySearcher searcher = CreateSearcher(rootEntry, currentTop)) { foreach (SearchResult result in searcher.FindAll()) { DirectoryEntry newEntry = result.GetDirectoryEntry(); if (!dResponse.ContainsKey(newEntry.Guid)) dResponse.Add(newEntry.Guid, newEntry); stack.Push(newEntry); } } } response.AddRange(dResponse.Values); } } private DirectorySearcher CreateSearcher(DirectoryEntry rootEntry, DirectoryEntry currentEntry) { DirectorySearcher searcher = new DirectorySearcher(rootEntry); PropertyValueCollection values = currentEntry.Properties[this.m_getPropertyName]; System.Diagnostics.Debug.Assert(values.Count == 1); searcher.Filter = "(" + this.m_searchPropertyName + "=" + values[0] + ")"; return searcher; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ReceiveActivityDesignerTheme.cs
- GZipDecoder.cs
- GroupBoxAutomationPeer.cs
- DrawingContextWalker.cs
- DesignerCommandAdapter.cs
- PropertyTabChangedEvent.cs
- SessionIDManager.cs
- FrameSecurityDescriptor.cs
- Propagator.Evaluator.cs
- HttpConfigurationContext.cs
- arabicshape.cs
- DesignerHelpers.cs
- EntityDataSourceMemberPath.cs
- CodeGenerator.cs
- CustomLineCap.cs
- PathData.cs
- CollectionViewGroupInternal.cs
- RouteParametersHelper.cs
- OdbcStatementHandle.cs
- CategoryAttribute.cs
- GridViewRowPresenterBase.cs
- XmlIterators.cs
- UrlMappingCollection.cs
- LongSumAggregationOperator.cs
- AppDomainShutdownMonitor.cs
- CodeTypeDeclarationCollection.cs
- PtsPage.cs
- PolicyDesigner.cs
- XmlWrappingWriter.cs
- Internal.cs
- HostedElements.cs
- PointCollection.cs
- SynchronizedDispatch.cs
- Region.cs
- DateTimeUtil.cs
- DiffuseMaterial.cs
- InternalResources.cs
- ExceptionDetail.cs
- HttpVersion.cs
- ErrorLog.cs
- DataError.cs
- RichTextBoxConstants.cs
- HyperLinkField.cs
- DataServiceConfiguration.cs
- RotateTransform.cs
- TemplateParser.cs
- SystemIPv4InterfaceProperties.cs
- DomainConstraint.cs
- BinaryNegotiation.cs
- DataGridViewCellStateChangedEventArgs.cs
- WinCategoryAttribute.cs
- SqlInternalConnectionSmi.cs
- WebHttpBinding.cs
- ActivityContext.cs
- COM2PictureConverter.cs
- DataGridViewRowPostPaintEventArgs.cs
- PointAnimationUsingKeyFrames.cs
- GridViewUpdateEventArgs.cs
- TreeViewAutomationPeer.cs
- RetriableClipboard.cs
- QualificationDataAttribute.cs
- AddingNewEventArgs.cs
- View.cs
- NativeCompoundFileAPIs.cs
- DependencyObjectProvider.cs
- NumberSubstitution.cs
- CanExecuteRoutedEventArgs.cs
- TimeSpanConverter.cs
- ConfigXmlReader.cs
- ImageSourceConverter.cs
- MailDefinition.cs
- GenericWebPart.cs
- WebHeaderCollection.cs
- ClassicBorderDecorator.cs
- RouteItem.cs
- MethodBuilder.cs
- RuleSettingsCollection.cs
- LiteralSubsegment.cs
- SelectedPathEditor.cs
- SettingsPropertyValueCollection.cs
- MobileComponentEditorPage.cs
- EdmFunction.cs
- UseManagedPresentationElement.cs
- XmlRootAttribute.cs
- FileDialogCustomPlacesCollection.cs
- ColorConverter.cs
- StreamGeometry.cs
- ContentValidator.cs
- TreeNodeMouseHoverEvent.cs
- GridViewCancelEditEventArgs.cs
- AutomationElementCollection.cs
- XmlBoundElement.cs
- EmissiveMaterial.cs
- TreeBuilderBamlTranslator.cs
- BinaryExpressionHelper.cs
- CheckStoreFileValidityRequest.cs
- DataGridCell.cs
- ReadingWritingEntityEventArgs.cs
- Command.cs
- XmlEncodedRawTextWriter.cs