public static void HandleException(Exception ex) { try //by nature, if this fails, its already handling an exception! { MMDBLogFile.Log(ex); } catch//(Exception x) { } }
public bool DeleteUser(string username) { try { Membership.DeleteUser(username); } catch (Exception err) { MMDBLogFile.Log(err); return(false); } return(true); }
public bool SaveProfile() { try { Profile.Save(); } catch (Exception err) { MMDBLogFile.Log(err); return(false); } return(true); }
public bool RemoveRole(string rolename) { try { if (Roles.RoleExists(rolename)) { Roles.DeleteRole(rolename); } } catch (Exception err) { MMDBLogFile.Log(err); return(false); } return(true); }
public bool AddRole(string rolename) { try { if (!Roles.RoleExists(rolename)) { Roles.CreateRole(rolename); } } catch (Exception err) { MMDBLogFile.Log(err); return(false); } return(true); }
public bool Login(string Username, string Password) { bool IsAuthenticated = false; try { IsAuthenticated = Membership.ValidateUser(Username, Password); Profile = ProfileBase.Create(Username, IsAuthenticated); } catch (Exception err) { MMDBLogFile.Log(err); return(false); } return(true); }
public bool IsAuthorized(string Username, string rule) { try { string[] roles = Roles.GetRolesForUser(Username); IPrincipal principal = new GenericPrincipal(new GenericIdentity(Username), roles); IAuthorizationProvider ruleProvider = AuthorizationFactory.GetAuthorizationProvider("RuleProvider"); return(ruleProvider.Authorize(principal, rule)); } catch (Exception err) { MMDBLogFile.Log(err); return(false); } }
public bool IsValid() { bool returnvalue = false; MMDBLicenser l = new MMDBLicenser(); try { string LicensePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\" + ConfigurationSettings.AppSettings["LicenseFile"].ToString(); returnvalue = l.IsValid(LicensePath, FeatureName, Passcode, false); } catch (Exception err) { MMDBLogFile.Log(err.Message); } return(returnvalue); }
public bool CreateUser(string Username, string Password, string Email, string Question, String Answer, out MembershipCreateStatus Status) { MembershipCreateStatus outStatus = MembershipCreateStatus.ProviderError; try { Membership.CreateUser(Username, Password, Email, Question, Answer, true, out outStatus); Profile = ProfileBase.Create(Username, true); } catch (Exception err) { MMDBLogFile.Log(err); Status = outStatus; return(false); } Status = outStatus; return(true); }
public static string Decrypt(string cipherString, bool useHashing) { try { byte[] keyArray; byte[] toEncryptArray = Convert.FromBase64String(cipherString); //Get your key from config file to open the lock! string key = (string)CypherKey; if (useHashing) { MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider(); keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key)); hashmd5.Clear(); } else { keyArray = UTF8Encoding.UTF8.GetBytes(key); } TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider(); tdes.Key = keyArray; tdes.Mode = CipherMode.ECB; tdes.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = tdes.CreateDecryptor(); byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); tdes.Clear(); return(UTF8Encoding.UTF8.GetString(resultArray)); } catch (Exception err) { MMDBLogFile.Log(err); return(""); } }