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
- EmptyStringExpandableObjectConverter.cs
- ReferencedCollectionType.cs
- ToolStripDropDownClosingEventArgs.cs
- SmiGettersStream.cs
- SettingsPropertyIsReadOnlyException.cs
- PackageProperties.cs
- HttpValueCollection.cs
- LineServicesCallbacks.cs
- InkCanvasSelectionAdorner.cs
- Variant.cs
- LoginView.cs
- LockedActivityGlyph.cs
- XmlIlVisitor.cs
- TcpAppDomainProtocolHandler.cs
- SvcMapFileSerializer.cs
- FixedSOMTable.cs
- RoleManagerModule.cs
- Pkcs9Attribute.cs
- XMLSyntaxException.cs
- StorageMappingItemLoader.cs
- DataGridViewAccessibleObject.cs
- CellQuery.cs
- XmlDataSourceNodeDescriptor.cs
- XmlSchemaAnnotation.cs
- KnownIds.cs
- ImageCodecInfoPrivate.cs
- WmlTextBoxAdapter.cs
- Comparer.cs
- ResolveNameEventArgs.cs
- CommandSet.cs
- IdentityHolder.cs
- XmlnsCompatibleWithAttribute.cs
- HwndSourceKeyboardInputSite.cs
- CapabilitiesAssignment.cs
- BaseParagraph.cs
- PtsCache.cs
- HtmlToClrEventProxy.cs
- DataGridViewColumnCollection.cs
- ZeroOpNode.cs
- DesignRelation.cs
- ToolStripRenderer.cs
- IdnElement.cs
- LinqDataSourceValidationException.cs
- MDIWindowDialog.cs
- RayHitTestParameters.cs
- BooleanExpr.cs
- InboundActivityHelper.cs
- UnmanagedBitmapWrapper.cs
- UIPropertyMetadata.cs
- InfoCardSymmetricCrypto.cs
- StyleCollection.cs
- EditorReuseAttribute.cs
- WindowsIdentity.cs
- OuterGlowBitmapEffect.cs
- ByteConverter.cs
- CommandBinding.cs
- KeyMatchBuilder.cs
- AccessDataSource.cs
- MemoryFailPoint.cs
- XmlWrappingReader.cs
- WorkBatch.cs
- FunctionQuery.cs
- BufferedGraphics.cs
- FirstMatchCodeGroup.cs
- SolidColorBrush.cs
- DbProviderSpecificTypePropertyAttribute.cs
- TraceSection.cs
- LookupNode.cs
- GenericParameterDataContract.cs
- TableLayoutStyle.cs
- CompilationUnit.cs
- XmlWrappingReader.cs
- _NativeSSPI.cs
- WebEventTraceProvider.cs
- HTMLTagNameToTypeMapper.cs
- UnsupportedPolicyOptionsException.cs
- CodeObjectCreateExpression.cs
- WindowsStatusBar.cs
- ThreadAbortException.cs
- SemaphoreSlim.cs
- MouseDevice.cs
- DNS.cs
- Context.cs
- ModelUIElement3D.cs
- DataGridViewColumnCollection.cs
- FormatConvertedBitmap.cs
- CodeAttributeDeclarationCollection.cs
- RijndaelManaged.cs
- DefaultSerializationProviderAttribute.cs
- ColorAnimationUsingKeyFrames.cs
- KeyedCollection.cs
- XmlSchemaValidationException.cs
- UnsafeNativeMethods.cs
- DateTimeFormat.cs
- DragCompletedEventArgs.cs
- GroupItemAutomationPeer.cs
- LineSegment.cs
- EventOpcode.cs
- ScrollableControlDesigner.cs
- GeneratedView.cs