Exemplo n.º 1
0
		public void Test_05_EventLogTest()
		{
			SmartEventLog sel = new SmartEventLog();
			
			Assert.IsTrue(sel.LogName.Equals("Application"),"Default Event Log should be application [" + sel.LogName + "]");			
			sel.WriteEntry( 1,11,EventLogEntryType.Information,"Test Event Log Message", new byte[] { 0x48, 0x65, 0x6c, 0x6c, 0x6f });
		}
Exemplo n.º 2
0
		/// <summary>
		/// This method will return the LDAP search engine based on the
		/// server name passed in.
		/// </summary>
		/// <remarks>If empty string is passed the default messaging profile will be checked for the
		/// MS Exchange (IMAPI) provider information.  If it is there the server entry from this 
		/// profile will be used.</remarks>
		/// <param name="serverName">The server name to search for.</param>
		/// <returns>The LDAP search engine interface</returns>
		/// <exception cref="NetworkException">If the servername is not valid or is available</exception>
		/// <exception cref="SecurityException">If the caller cannot access the server</exception>
		/// <exception cref="ArgumentNullException">If the servername is empty</exception>
		/// <exception cref="LdapException">If the server is not a recognised Ldap Server</exception>
		public static ILdapSearchEngine GetSearchEngine(string serverName)
		{
			string server = "";
			// Check if empty and if so then get the default profile exchange server
			if (serverName.Length == 0)
				serverName = GetDefaultExchangeServer();

			// Check to see if we have passed in the port number as well
			if (serverName.IndexOf(":") > -1)
			{
				server = serverName.Substring(0, serverName.IndexOf(":"));
			}
			else
				server = serverName;

			// If still empty then throw a wobbly
			if (serverName.Length == 0)
			{
				throw new ArgumentNullException("serverName", SmartResourceManager.GetString("ELD_003",
					"Workshare.Common.Exceptions.Resources", Assembly.GetAssembly(typeof(LdapSearcher)),
					SmartResourceManager.CurrentCulture));
			}
			// Check to see if the server is available
			// This will throw a networkexception if the server is not in the DNS, but 
			// will return false if it is not available on the network.
			try
			{
				if (!SmartDetect.Ping(server))
				{
					SmartEventLog sel = new SmartEventLog();
					string msg = SmartResourceManager.GetString("ELD_005",
						"Workshare.Common.Exceptions.Resources", Assembly.GetAssembly(typeof(LdapSearcher)),
						SmartResourceManager.CurrentCulture);
					StringBuilder sb = new StringBuilder();
					sb.AppendFormat(msg, serverName);

					sel.WriteEntry(1, 1, EventLogEntryType.Warning, sb.ToString());
				}
			}
			catch (System.Net.Sockets.SocketException)
			{
				// More than likely we are running under normal account conditions
			}
			return FindEngine(serverName);
		}