1 /******************************************************************************
3 * Copyright (c) 2003 Novell Inc., www.novell.com
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the Software), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 *******************************************************************************/
25 // System.DirectoryServices.SearchResult.cs
28 // Sunil Kumar (sunilk@novell.com)
33 using System.ComponentModel;
34 using Novell.Directory.Ldap;
35 using System.Collections.Specialized;
37 namespace System.DirectoryServices
41 ///Encapsulates a node or object in the Ldap Directory hierarchy.
43 public class SearchResult
46 private string _Path=null;
47 private ResultPropertyCollection _Properties=null;
48 private DirectoryEntry _Entry=null;
49 private StringCollection _PropsToLoad=null;
50 private bool ispropnull=true;
51 private PropertyCollection _Rproperties = null;
53 internal PropertyCollection Rproperties
61 private void InitBlock()
70 internal StringCollection PropsToLoad
74 if( _PropsToLoad != null )
83 /// Gets a ResultPropertyCollection of properties set on this object.
86 /// A ResultPropertyCollection of properties set on this object.
89 /// This collection only contains properties that were explicitly
90 /// requested through DirectorySearcher.PropertiesToLoad.
92 public ResultPropertyCollection Properties
98 _Properties= new ResultPropertyCollection();
99 System.Collections.IDictionaryEnumerator id =
100 Rproperties.GetEnumerator();
101 // _Entry.Properties.GetEnumerator();
104 string attribute=(string)id.Key;
105 ResultPropertyValueCollection rpVal=
106 new ResultPropertyValueCollection();
107 if(Rproperties[attribute].Count==1)
109 String val = (String)Rproperties[attribute].Value;
112 else if (Rproperties[attribute].Count > 1)
114 Object[] vals=(Object [])Rproperties[attribute].Value;
115 // String[] aStrVals= new String[_Entry.Properties[attribute].Count];
116 rpVal.AddRange(vals);
118 _Properties.Add(attribute,rpVal);
126 internal SearchResult(DirectoryEntry entry)
133 internal SearchResult(DirectoryEntry entry, PropertyCollection props)
138 _Rproperties = props;
141 /// Gets the path for this SearchResult.
144 /// The path of this SearchResult.
147 /// The Path property uniquely identifies this entry in the Active
148 /// Directory hierarchy. The entry can always be retrieved using this
160 /// Retrieves the DirectoryEntry that corresponds to the SearchResult,
161 /// from the Active Directory hierarchy.
164 /// The DirectoryEntry that corresponds to the SearchResult
167 /// Use GetDirectoryEntry when you want to look at the live entry
168 /// instead of the entry returned through DirectorySearcher, or when
169 /// you want to invoke a method on the object that was returned.
171 public DirectoryEntry GetDirectoryEntry()