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
- DataSet.cs
- EntityDesignerUtils.cs
- BitmapEffect.cs
- XPathBuilder.cs
- DbConnectionPoolGroup.cs
- SqlWriter.cs
- XmlMtomWriter.cs
- StylusPlugin.cs
- HtmlInputRadioButton.cs
- cookie.cs
- SRGSCompiler.cs
- PropagatorResult.cs
- CharUnicodeInfo.cs
- PermissionSetEnumerator.cs
- TableParaClient.cs
- UriWriter.cs
- TabControlToolboxItem.cs
- Line.cs
- TriState.cs
- VirtualPathProvider.cs
- DatagridviewDisplayedBandsData.cs
- ConvertersCollection.cs
- PropertyInformation.cs
- SecurityPermission.cs
- FileUpload.cs
- webclient.cs
- ZipIOModeEnforcingStream.cs
- Resources.Designer.cs
- ConfigurationManagerHelper.cs
- PassportAuthentication.cs
- SecurityState.cs
- XAMLParseException.cs
- TemplateBindingExpression.cs
- SqlDependencyUtils.cs
- RootNamespaceAttribute.cs
- ViewGenerator.cs
- CapabilitiesPattern.cs
- OrderPreservingPipeliningMergeHelper.cs
- StylusButtonCollection.cs
- NameNode.cs
- TypeGeneratedEventArgs.cs
- BuildManager.cs
- SystemUnicastIPAddressInformation.cs
- UriWriter.cs
- TreeView.cs
- APCustomTypeDescriptor.cs
- ListViewGroupItemCollection.cs
- CacheSection.cs
- PrintDialog.cs
- GeneratedContractType.cs
- CommonEndpointBehaviorElement.cs
- PeerNameResolver.cs
- OptionUsage.cs
- JpegBitmapDecoder.cs
- FieldValue.cs
- BrushMappingModeValidation.cs
- SplitterCancelEvent.cs
- XmlQualifiedName.cs
- ListBindingConverter.cs
- LabelDesigner.cs
- TypedOperationInfo.cs
- sqlnorm.cs
- Parameter.cs
- PackagePart.cs
- DefaultValueConverter.cs
- WsdlBuildProvider.cs
- OverrideMode.cs
- CoTaskMemHandle.cs
- SoapClientProtocol.cs
- DataBindingExpressionBuilder.cs
- ManagementObjectCollection.cs
- WebPartManagerInternals.cs
- DynamicDataResources.Designer.cs
- ConditionalWeakTable.cs
- ConditionValidator.cs
- XamlStream.cs
- _SSPIWrapper.cs
- DocumentXPathNavigator.cs
- StorageInfo.cs
- RolePrincipal.cs
- ProfileGroupSettingsCollection.cs
- GridViewSelectEventArgs.cs
- Misc.cs
- Image.cs
- IgnoreFileBuildProvider.cs
- ControlValuePropertyAttribute.cs
- SafeEventLogReadHandle.cs
- LabelExpression.cs
- EntityProviderFactory.cs
- SByteStorage.cs
- CultureInfoConverter.cs
- BindingNavigator.cs
- UnsafeNativeMethods.cs
- _ChunkParse.cs
- CompiledQueryCacheKey.cs
- EncoderFallback.cs
- ConditionalAttribute.cs
- processwaithandle.cs
- WindowsComboBox.cs
- ForeignConstraint.cs