* support-test-*.cs: Rename from test-*-p2.cs.
[mono.git] / mcs / class / System.DirectoryServices / Test / System.DirectoryServices / TestConfiguration.cs
1 using System;\r
2 using System.DirectoryServices;\r
3 using System.Collections.Specialized;\r
4 using System.Configuration;\r
5 \r
6 namespace MonoTests.System.DirectoryServices \r
7 {\r
8         public class TestConfiguration\r
9         {\r
10                 #region Fields\r
11 \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
17 \r
18                 #endregion // Fields\r
19 \r
20                 #region Constructors\r
21 \r
22                 public TestConfiguration()\r
23                 {\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
29 \r
30                                 _baseDn = config ["basedn"];\r
31 \r
32                                 _username = config ["username"];\r
33                                 _password = config ["password"];\r
34 \r
35                                 string authType = config ["authenticationtype"];\r
36 \r
37                                 string [] authTypes = authType.Split (new char[] { '|' });\r
38 \r
39                                 _authenticationType = (AuthenticationTypes) 0;\r
40 \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
45                         }\r
46 \r
47                         //Console.WriteLine ("Connecting to {0} with credentials {1}:{2} and security {3}",ConnectionString,Username,Password,AuthenticationType);\r
48                 }\r
49 \r
50                 #endregion // Constructors\r
51 \r
52                 #region Properties\r
53 \r
54                 public string ServerRoot\r
55                 {\r
56                         get { return _serverRoot; }\r
57                 }\r
58 \r
59                 public string BaseDn\r
60                 {\r
61                         get { return ((_baseDn == null) ? String.Empty : _baseDn); }\r
62                 }\r
63 \r
64                 public string ConnectionString\r
65                 { \r
66                         get { return ServerRoot + ((BaseDn.Length == 0) ? String.Empty : BaseDn); }\r
67                 }\r
68 \r
69                 public string Username\r
70                 {\r
71                         get{ return _username; }\r
72                 }\r
73 \r
74                 public string Password\r
75                 {\r
76                         get { return _password; }\r
77                 }\r
78 \r
79                 public AuthenticationTypes AuthenticationType\r
80                 {\r
81                         get { return _authenticationType; }\r
82                 }\r
83 \r
84                 #endregion // Properties\r
85         }\r
86 }\r