public static bool Detect() { #region How to Used -- PS. Copy and Paste Coding below . Note Remember unremark it... // bool iscookie; // // iscookie = Detect() ; // // if(iscookie) // { // DateTime dtNow = DateTime.Now; // HttpCookieCollection cookies = Request.Cookies; // HttpCookie cookie = cookies["_ytra"]; // // try // { // string str = cookies["_ytra"].Value; // } // catch // { // HttpCookie newcookie = new HttpCookie("_ytra"); // newcookie.Expires = DateTime.Now.AddHours(24); /* cookie expire after 24hr.*/ // Response.Cookies.Add(newcookie); // Response.Redirect("http://promos.domain.com/intercept/default.asp?ru=" + Request.Url.AbsoluteUri); /* remarks this line to disable intercept */ // } // } #endregion const string cookie_name = "_ytra"; const string querystring_name = "q"; bool _isenabled = false; // Need this to display properly in designer if (HttpContext.Current == null) { return(false); } // Get Session and Request objects HttpRequest Request = HttpContext.Current.Request; HttpResponse Response = HttpContext.Current.Response; // Perform redirect test if (Request.Form.Count == 0 && Request.Cookies[cookie_name] == null && Request.QueryString[querystring_name] == null) { string Q = Request.QueryString.ToString(); if (Q.Length > 0) { Q = "?" + Q + "&"; } else { Q = "?"; } Q += querystring_name + "=true"; Response.Cookies.Add(new HttpCookie(cookie_name, "_o")); Response.Cookies["_ytra"].Expires = DateTime.Parse("01/10/2030"); if (!string.IsNullOrEmpty(DefaultDomain) && DefaultDomain.ToLower() != "localhost") { Response.Cookies["_ytra"].Domain = DefaultDomain; } Response.Redirect(Request.Path + Q); } if (Request.Cookies[cookie_name] != null) { _isenabled = true; } return(_isenabled); }
/// <summary> /// Gets the LDAP path to be used when querying a specific domain. /// </summary> /// <param name="domain">The domain.</param> /// <returns> /// The LDAP path, eg LDAP://hostname. /// </returns> public string LdapPathForDomain(string domain) { if (_generalSettings != null) { var value = _generalSettings["LdapPath." + domain]; if (String.IsNullOrEmpty(value) && (String.IsNullOrEmpty(domain) || domain.ToUpperInvariant() == DefaultDomain?.ToUpperInvariant())) { value = _generalSettings["LdapPath"]; } return(value); } return(String.Empty); }