2 // Mono.Directory.LDAP.LDAPMessage
5 // Chris Toshok (toshok@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
10 // Just enough (for now) LDAP support to get System.DirectoryServices
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using System.Runtime.InteropServices;
37 namespace Mono.Directory.LDAP
39 public class LDAPMessage {
41 internal LDAPMessage(LDAP ld, IntPtr ldm) {
46 public LDAPMessage FirstMessage () {
47 IntPtr nm = ldap_first_message (ld.NativeLDAP ,ldm);
49 if (nm == IntPtr.Zero)
52 return new LDAPMessage (ld, nm);
55 public LDAPMessage NextMessage () {
56 IntPtr nm = ldap_next_message (ld.NativeLDAP ,ldm);
58 if (nm == IntPtr.Zero)
61 return new LDAPMessage (ld, nm);
64 public int CountMessages () {
65 return ldap_count_messages (ld.NativeLDAP, ldm);
68 public LDAPMessage FirstEntry() {
69 IntPtr nm = ldap_first_entry (ld.NativeLDAP ,ldm);
71 if (nm == IntPtr.Zero)
74 return new LDAPMessage (ld, nm);
77 public LDAPMessage NextEntry() {
78 IntPtr nm = ldap_next_entry (ld.NativeLDAP ,ldm);
80 if (nm == IntPtr.Zero)
83 return new LDAPMessage (ld, nm);
86 public int CountEntries() {
87 return ldap_count_entries (ld.NativeLDAP, ldm);
91 get { return ldap_get_dn (ld.NativeLDAP, ldm); }
95 public string[] GetValues (string target) {
96 throw new NotImplementedException ();
100 Console.WriteLine ("calling ldap_get_values ({0})", target);
102 ldap_values = ldap_get_values (ld.NativeLDAP, ldm, target);
104 if (ldap_values != null) {
108 rv = new string[ldap_values.Length - 1];
109 for (i = 0; i < ldap_values.Length - 1; i ++)
110 rv[i] = ldap_values[i];
121 extern static string ldap_get_dn (IntPtr ld, IntPtr ldm);
124 extern static IntPtr ldap_first_message (IntPtr ld, IntPtr ldm);
127 extern static IntPtr ldap_next_message (IntPtr ld, IntPtr ldm);
130 extern static int ldap_count_messages (IntPtr ld, IntPtr ldm);
133 extern static IntPtr ldap_first_entry (IntPtr ld, IntPtr ldm);
136 extern static IntPtr ldap_next_entry (IntPtr ld, IntPtr ldm);
139 extern static int ldap_count_entries (IntPtr ld, IntPtr ldm);
142 extern static string ldap_first_attribute (IntPtr ld, IntPtr ldm, out IntPtr ber);
145 extern static string ldap_next_attribute (IntPtr ld, IntPtr ldm, IntPtr ber);
148 [DllImport("ldapglue")]
149 extern static void ldapsharp_get_values (IntPtr ld, IntPtr ldm, string target,
150 out string[] values, out int count);