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
- PrintDialogDesigner.cs
- GridViewUpdateEventArgs.cs
- DataGridHeaderBorder.cs
- BamlBinaryWriter.cs
- TreeViewImageKeyConverter.cs
- GiveFeedbackEventArgs.cs
- QualifiedCellIdBoolean.cs
- ReachUIElementCollectionSerializer.cs
- Button.cs
- RegexBoyerMoore.cs
- BitmapScalingModeValidation.cs
- relpropertyhelper.cs
- XmlDataProvider.cs
- StdValidatorsAndConverters.cs
- InputProcessorProfilesLoader.cs
- RightsManagementEncryptedStream.cs
- xml.cs
- LockCookie.cs
- ProtocolsSection.cs
- BaseComponentEditor.cs
- ForceCopyBuildProvider.cs
- DataChangedEventManager.cs
- SpeechSynthesizer.cs
- XsdCachingReader.cs
- HtmlInputText.cs
- EtwTrace.cs
- WebPartDesigner.cs
- Base64Stream.cs
- AdapterDictionary.cs
- RequestUriProcessor.cs
- AssemblyInfo.cs
- DateTimeValueSerializerContext.cs
- IdentityHolder.cs
- CellQuery.cs
- SiteMapNodeCollection.cs
- TypefaceMetricsCache.cs
- SqlRetyper.cs
- ListViewEditEventArgs.cs
- RawStylusActions.cs
- ClockGroup.cs
- SafeFileMapViewHandle.cs
- SettingsPropertyValue.cs
- BuildManager.cs
- OAVariantLib.cs
- EmptyEnumerator.cs
- WebServiceEndpoint.cs
- ManifestSignedXml.cs
- CheckPair.cs
- UnsettableComboBox.cs
- PackWebRequestFactory.cs
- RadioButtonList.cs
- securestring.cs
- RegionData.cs
- InvalidDataException.cs
- EventLogger.cs
- Schedule.cs
- HandlerBase.cs
- SQLDateTime.cs
- Missing.cs
- Error.cs
- WindowsListViewGroupHelper.cs
- ModifierKeysConverter.cs
- EntityDataSourceView.cs
- TextPointer.cs
- ExpressionDumper.cs
- XmlArrayItemAttributes.cs
- GPPOINTF.cs
- MSHTMLHost.cs
- RegistryExceptionHelper.cs
- LayoutTableCell.cs
- ListViewPagedDataSource.cs
- SimpleExpression.cs
- Int32RectConverter.cs
- CqlWriter.cs
- DialogResultConverter.cs
- MsmqBindingBase.cs
- ObjectQuery.cs
- AutoSizeToolBoxItem.cs
- HMACSHA256.cs
- TypeViewSchema.cs
- RootBrowserWindow.cs
- EntityParameter.cs
- _DigestClient.cs
- SqlCharStream.cs
- FixUp.cs
- FreeFormPanel.cs
- ReturnType.cs
- TabControl.cs
- OuterGlowBitmapEffect.cs
- CodeAttributeDeclaration.cs
- SqlInfoMessageEvent.cs
- HttpClientCertificate.cs
- ResourceType.cs
- SqlMethodTransformer.cs
- ReflectionTypeLoadException.cs
- DebuggerAttributes.cs
- DesignTimeData.cs
- SecurityRuntime.cs
- XmlDataSource.cs
- ProxySimple.cs