1 diff -Naur lat.orig/ServiceFinder.cs lat/ServiceFinder.cs
2 --- lat.orig/ServiceFinder.cs 1970-01-01 01:00:00.000000000 +0100
3 +++ lat/ServiceFinder.cs 2006-09-04 22:27:08.000000000 +0200
6 +// lat - ServiceFinder.cs
7 +// Author: Loren Bandiera
8 +// Copyright 2005-2006 MMG Security, Inc.
10 +// This program is free software; you can redistribute it and/or modify
11 +// it under the terms of the GNU General Public License as published by
12 +// the Free Software Foundation; Version 2
14 +// This program is distributed in the hope that it will be useful,
15 +// but WITHOUT ANY WARRANTY; without even the implied warranty of
16 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 +// GNU General Public License for more details.
19 +// You should have received a copy of the GNU General Public License
20 +// along with this program; if not, write to the Free Software
21 +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 + public class ServiceEventArgs : EventArgs
34 + public ServiceEventArgs (Connection conn)
39 + public Connection FoundConnection
41 + get { return conn; }
45 + public delegate void ServiceEventHandler (object o, ServiceEventArgs args);
47 + public class ServiceFinder
52 + public event ServiceEventHandler Found;
54 + public ServiceFinder ()
56 + client = new Client();
59 + public void Start ()
62 + sb = new ServiceBrowser (client, "_ldap._tcp");
63 + sb.ServiceAdded += OnServiceAdded;
64 + sb.ServiceRemoved += OnServiceRemoved;
65 + } catch (ClientException ce) {
75 + void OnServiceResolved (object o, ServiceInfoArgs args)
77 + (o as ServiceResolver).Dispose ();
79 + ConnectionData cd = new ConnectionData ();
80 + cd.Name = String.Format ("{0} ({1})", args.Service.Name, args.Service.Address);
81 + cd.Host = args.Service.Address.ToString ();
82 + cd.Port = args.Service.Port;
85 + cd.SavePassword = false;
86 + cd.ServerType = Util.GetServerType ("Generic LDAP server");
89 + Log.Debug ("Found LDAP service {0} on {1} port {2}",
90 + args.Service.Name, args.Service.Address, args.Service.Port);
92 + if (args.Service.Port == 636)
93 + cd.Encryption = EncryptionType.SSL;
95 + Connection conn = new Connection (cd);
98 + Found (this, new ServiceEventArgs (conn));
101 + void OnServiceAdded (object o, ServiceInfoArgs args)
103 + ServiceResolver resolver = new ServiceResolver (client, args.Service);
104 + resolver.Found += OnServiceResolved;
107 + void OnServiceRemoved (object o, ServiceInfoArgs args)