This repository was archived by the owner on Jun 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
46 lines (37 loc) · 1.43 KB
/
Program.cs
File metadata and controls
46 lines (37 loc) · 1.43 KB
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
using System;
using System.Collections.Generic;
using System.DirectoryServices.Protocols;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LinqToLdap;
using SharpTestsEx;
namespace ServerPoolConnectionFactory
{
class Program
{
static void Main(string[] args)
{
var config = new LdapConfiguration();
var factory = new PooledServerConnectionFactory();
factory.AddServer(new LdapDirectoryIdentifier("localhost", 389), 1);
factory.AddServer(new LdapDirectoryIdentifier("computername", 389), 1);
config.ConfigureCustomFactory(factory);
var connection1 = config.ConnectionFactory.GetConnection();
connection1.GetServerName().Satisfy(s => s.Equals("localhost") || s.Equals("computername"));
var connection2 = config.ConnectionFactory.GetConnection();
connection2.GetServerName().Satisfy(s => s.Equals("localhost") || s.Equals("computername"));
Action action = () => config.ConnectionFactory.GetConnection();
action.Should().Throw<InvalidOperationException>();
Console.WriteLine("all is well");
Console.ReadLine();
}
}
public static class Extensions
{
public static string GetServerName(this LdapConnection connection)
{
return ((LdapDirectoryIdentifier) connection.Directory).Servers[0];
}
}
}