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
- RequestUriProcessor.cs
- OleTxTransaction.cs
- IntellisenseTextBox.designer.cs
- ImageBrush.cs
- ToolboxComponentsCreatedEventArgs.cs
- VisemeEventArgs.cs
- Int64Converter.cs
- PrintingPermission.cs
- DataGridViewAdvancedBorderStyle.cs
- RegexWorker.cs
- MulticastOption.cs
- ImageDrawing.cs
- XmlTextReader.cs
- XPathCompileException.cs
- OdbcCommand.cs
- SafeHandles.cs
- DataSourceHelper.cs
- BoolLiteral.cs
- BasicBrowserDialog.cs
- SR.cs
- DayRenderEvent.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- Helper.cs
- BCLDebug.cs
- ExpressionEditorAttribute.cs
- DoubleConverter.cs
- MemberDescriptor.cs
- DataSourceXmlSubItemAttribute.cs
- TextElementAutomationPeer.cs
- AmbientLight.cs
- FilteredDataSetHelper.cs
- SerializerDescriptor.cs
- AuthStoreRoleProvider.cs
- GeometryHitTestParameters.cs
- WindowsScrollBarBits.cs
- DataRowView.cs
- SortedSet.cs
- HotSpot.cs
- DeploymentSectionCache.cs
- ItemList.cs
- XmlNodeReader.cs
- SafeNativeMemoryHandle.cs
- InkCanvasFeedbackAdorner.cs
- LambdaSerializationException.cs
- PaperSize.cs
- ContractUtils.cs
- NotImplementedException.cs
- List.cs
- WindowsAltTab.cs
- CompatibleIComparer.cs
- CacheAxisQuery.cs
- StylusPointPropertyInfo.cs
- ColumnResult.cs
- InputScope.cs
- EntityModelSchemaGenerator.cs
- AddValidationError.cs
- NameValueCollection.cs
- RegexFCD.cs
- DES.cs
- PopOutPanel.cs
- DocobjHost.cs
- TextRunCache.cs
- Gdiplus.cs
- SqlDataSourceConfigureSelectPanel.cs
- SiteMembershipCondition.cs
- QueryStringParameter.cs
- SliderAutomationPeer.cs
- Pipe.cs
- HttpCacheVaryByContentEncodings.cs
- XsltContext.cs
- XmlSerializableServices.cs
- COM2Properties.cs
- BackgroundWorker.cs
- SoapExtension.cs
- SerializerWriterEventHandlers.cs
- ExpressionBuilder.cs
- ParameterToken.cs
- ArgIterator.cs
- VisualProxy.cs
- TimeZoneNotFoundException.cs
- SchemaImporter.cs
- DataConnectionHelper.cs
- StoreAnnotationsMap.cs
- SqlTriggerAttribute.cs
- ProcessHostFactoryHelper.cs
- InlineCollection.cs
- ACE.cs
- CaseInsensitiveOrdinalStringComparer.cs
- DropShadowBitmapEffect.cs
- Point.cs
- TextTreeObjectNode.cs
- OleDbReferenceCollection.cs
- XsltException.cs
- TextFragmentEngine.cs
- X509SecurityToken.cs
- ApplicationContext.cs
- XPathParser.cs
- PageOrientation.cs
- ExpressionNormalizer.cs
- WebPartConnectionsCancelVerb.cs