2 using System.DirectoryServices;
\r
3 using System.Collections.Specialized;
\r
4 using System.Configuration;
\r
6 namespace MonoTests.System.DirectoryServices
\r
8 public class TestConfiguration
\r
12 private string _serverRoot;
\r
13 private string _username;
\r
14 private string _password;
\r
15 private string _baseDn;
\r
16 private AuthenticationTypes _authenticationType;
\r
18 #endregion // Fields
\r
20 #region Constructors
\r
22 public TestConfiguration()
\r
24 NameValueCollection config = (NameValueCollection) ConfigurationSettings.GetConfig ("System.DirectoryServices.Test/Settings");
\r
25 if (config != null) {
\r
26 string servername = config ["servername"];
\r
27 string port = config ["port"];
\r
28 _serverRoot = "LDAP://" + servername + (port.Equals ("389") ? String.Empty : (":" + port)) + "/";
\r
30 _baseDn = config ["basedn"];
\r
32 _username = config ["username"];
\r
33 _password = config ["password"];
\r
35 string authType = config ["authenticationtype"];
\r
37 string [] authTypes = authType.Split (new char[] { '|' });
\r
39 _authenticationType = (AuthenticationTypes) 0;
\r
41 foreach (string s in authTypes)
\r
42 foreach (AuthenticationTypes type in Enum.GetValues (typeof (AuthenticationTypes)))
\r
43 if (s.Trim ().Equals (type.ToString ()))
\r
44 _authenticationType |= type;
\r
47 //Console.WriteLine ("Connecting to {0} with credentials {1}:{2} and security {3}",ConnectionString,Username,Password,AuthenticationType);
\r
50 #endregion // Constructors
\r
54 public string ServerRoot
\r
56 get { return _serverRoot; }
\r
59 public string BaseDn
\r
61 get { return ((_baseDn == null) ? String.Empty : _baseDn); }
\r
64 public string ConnectionString
\r
66 get { return ServerRoot + ((BaseDn.Length == 0) ? String.Empty : BaseDn); }
\r
69 public string Username
\r
71 get{ return _username; }
\r
74 public string Password
\r
76 get { return _password; }
\r
79 public AuthenticationTypes AuthenticationType
\r
81 get { return _authenticationType; }
\r
84 #endregion // Properties
\r