blob: f8ae967b2805515344eabf8b61ce61f1fbce8ebc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// QueryRootDSETest.cs
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
//
// (C) 2003 Martin Willemoes Hansen
//
using System;
using NUnit.Framework;
using Mono.Directory.LDAP;
namespace MonoTests.Directory.LDAP
{
[TestFixture]
public class QueryRootDSETest {
[Test]
public void Stuff()
{
string myLDAPPath = "ldap://ldap.toshok.org";
try {
LDAP ld = new LDAP (myLDAPPath);
LDAPMessage res, entry;
string[] attrs = { "+", null };
/* don't bind, we do this anonymously */
ld.Search ("" /* root dse */,
SearchScope.Base,
"(objectclass=*)",
attrs, false,
TimeSpan.FromSeconds(10), 0 /* no size limit */,
out res);
if (res == null) {
Console.WriteLine ("the search failed");
}
Console.WriteLine ("There are {0} entries", res.CountEntries());
entry = res.FirstEntry();
if (entry == null)
Console.WriteLine ("null returned from res.FirstEntry");
string[] extensions = entry.GetValues ("supportedExtension");
if (extensions != null) {
foreach( String e in extensions )
Console.WriteLine ("Supported Extension: {0}\n", e);
}
else {
Console.WriteLine ("null returned from entry.GetValues\n");
}
}
catch(Exception e) {
Console.WriteLine("The '" + myLDAPPath + "' path not found.");
Console.WriteLine("Exception : " + e.Message);
Console.WriteLine(e.StackTrace);
}
}
}
}
|