public static string SendeMail(string eMailTo, string eMailCC, string eMailBcc, string eMailForm, string eMailSubject, string eMailBody, string eMailFormat) { try { if (WebConfig.eMailGo() == "Test") { eMailBody = eMailBody.Replace("{{PlaceHolder:TestEmailTo}}", "Email To: " + eMailTo); eMailBody = eMailBody.Replace("{{PlaceHolder:TestEmailCC}}", "Email CC: " + eMailCC); eMailTo = eMailForm; eMailCC = "*****@*****.**"; eMailBcc = ""; } else { eMailBody = eMailBody.Replace("{{PlaceHolder:TestEmailTo}}", ""); eMailBody = eMailBody.Replace("{{PlaceHolder:TestEmailCC}}", ""); } if (eMailFormat == "HTML") { // string pageHeader = "<!DOCTYPE> <html xmlns='http://www.w3.org/1999/xhtml'> < head > < style > body {width: 800px;} </ style > </ head > < body > < div > "; string pageHeader = "< !DOCTYPE html > < html > < head > < title ></ title > </ head > < body > <div> "; string pageFooter = "</ div> </ body > </ html > "; string appUrl = " <a href=' " + WebConfig.getValuebyKey("ApplicationSite") + "' target='_blank'> Teacher Performance Appraisal </a>"; eMailBody = eMailBody.Replace("{{PlaceHolder:WebSite}}", appUrl); eMailBody = eMailBody.Replace("{{PlaceHolder:OneLine}}", "<br />"); eMailBody = pageHeader + eMailBody + pageFooter; } else { eMailBody = eMailBody.Replace("{{PlaceHolder:WebSite}}", WebConfig.getValuebyKey("ApplicationSite")); eMailBody = eMailBody.Replace("{{PlaceHolder:OneLine}}", ""); } // NotificationeMail("Save", userID, schoolyear, schoolcode, employeeID, noticeType, noticeDate, deadlineDate, deadlineDate, eMailSubject, eMailBody); string result = AssemblingeMail(eMailTo, eMailCC, eMailBcc, eMailForm, eMailSubject, eMailBody, eMailFormat); return(result); } catch (Exception ex) { var em = ex.Message; return(""); } }
public static bool IsAuthenticated(string _domain, string username, string pwd) { try { string authenticationMethod = WebConfig.getValuebyKey("AuthenticateMethod"); if (authenticationMethod == "NameOnly") { return(true); } else { string _path = WebConfig.getValuebyKey("LDAP"); string domainAndUsername = _domain + "'\'" + username; DirectoryEntry entry = new DirectoryEntry(_path, username, pwd); try { Object obj = entry.NativeObject; // .NativeObject; DirectorySearcher search = new DirectorySearcher(entry); search.Filter = "(SAMAccountName=" + username + ")"; search.PropertiesToLoad.Add("cn"); SearchResult result = search.FindOne(); if (result == null) { return(false); } else { return(true); } } catch (Exception ex) { string em = ex.Message; return(false);; } } } catch (Exception ex) { string myEx = ex.Message; return(false); } }
public static bool IsAuthenticated1(string _domain, string username, string pwd) { string _path = WebConfig.getValuebyKey("LDAP"); string domainAndUsername = _domain + "\\" + username; DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd); try { Object obj = entry.NativeObject; DirectorySearcher search = new DirectorySearcher(entry); search.Filter = "(SAMAccountName=" + username + ")"; search.PropertiesToLoad.Add("cn"); SearchResult result = search.FindOne(); if (result == null) { return(false); } else { return(true); } //update the new path to the user in directory // _path = result.Path; // string _filterAttribute = System.Convert.ToString(result.Properties("cn")(0)); } catch (Exception ex) { // throw new Exception("Error authenticating user." + ex.Message); var exm = ex.Message; return(false); } }