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
- WebPartsPersonalization.cs
- ReadOnlyDictionary.cs
- DNS.cs
- MappingModelBuildProvider.cs
- StoreContentChangedEventArgs.cs
- ArgumentsParser.cs
- LOSFormatter.cs
- CompositeFontParser.cs
- ItemDragEvent.cs
- XPathNodeHelper.cs
- XmlSortKey.cs
- safex509handles.cs
- PerfService.cs
- Helper.cs
- ServiceHostingEnvironment.cs
- KerberosSecurityTokenProvider.cs
- GroupLabel.cs
- EntityDataSourceConfigureObjectContext.cs
- XamlBrushSerializer.cs
- DrawingContextWalker.cs
- SystemColors.cs
- Slider.cs
- SiteMapHierarchicalDataSourceView.cs
- XmlCountingReader.cs
- ListBoxChrome.cs
- DataListItemEventArgs.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- NumberSubstitution.cs
- ConfigurationValidatorBase.cs
- LastQueryOperator.cs
- SHA384Cng.cs
- ParentQuery.cs
- FileDetails.cs
- BinaryObjectWriter.cs
- VirtualizingPanel.cs
- mediaeventshelper.cs
- NotificationContext.cs
- FlowDocumentReaderAutomationPeer.cs
- OciEnlistContext.cs
- SerialReceived.cs
- GridViewSortEventArgs.cs
- BitmapSizeOptions.cs
- DataGridViewCellConverter.cs
- BlockUIContainer.cs
- FollowerQueueCreator.cs
- DbException.cs
- NullableLongSumAggregationOperator.cs
- SmtpReplyReaderFactory.cs
- FixedSOMFixedBlock.cs
- StylusPointProperties.cs
- HttpModulesSection.cs
- TemplatePartAttribute.cs
- InvokeProviderWrapper.cs
- XamlPointCollectionSerializer.cs
- counter.cs
- FlowNode.cs
- DataGridViewSelectedRowCollection.cs
- TypeSource.cs
- SQLConvert.cs
- CommonProperties.cs
- ReflectionUtil.cs
- Graphics.cs
- DataControlField.cs
- ClientOptions.cs
- MatrixAnimationUsingPath.cs
- AggregatePushdown.cs
- Html32TextWriter.cs
- FileAuthorizationModule.cs
- DecoratedNameAttribute.cs
- ResourceWriter.cs
- Themes.cs
- EventEntry.cs
- MetafileHeader.cs
- SQLDateTime.cs
- XmlSubtreeReader.cs
- _TLSstream.cs
- ImageCodecInfo.cs
- HttpHandlersSection.cs
- Operand.cs
- GridViewSortEventArgs.cs
- NullRuntimeConfig.cs
- counter.cs
- ListBoxItemAutomationPeer.cs
- TransformGroup.cs
- IgnoreFlushAndCloseStream.cs
- CodeArgumentReferenceExpression.cs
- PageParserFilter.cs
- HttpServerVarsCollection.cs
- Crypto.cs
- MessageQueueConverter.cs
- EventBindingService.cs
- BaseAsyncResult.cs
- DataKeyCollection.cs
- WebPartsSection.cs
- QueryTaskGroupState.cs
- SecurityTokenValidationException.cs
- ObjectSet.cs
- CoTaskMemUnicodeSafeHandle.cs
- MsmqTransportSecurityElement.cs
- SafeEventLogWriteHandle.cs