public string SetNewPassword(string AUserID, string AToken, string ANewPassword) { TVerificationResultCollection VerificationResult; bool Result = TMaintenanceWebConnector.SetNewPassword(AUserID, AToken, ANewPassword, out VerificationResult); return("{" + "\"AVerificationResult\": " + THttpBinarySerializer.SerializeObject(VerificationResult) + "," + "\"result\": " + THttpBinarySerializer.SerializeObject(Result) + "}"); }
public string GetUserInfo() { if (UserInfo.GUserInfo == null) { return(THttpBinarySerializer.SerializeObject(false)); } return(THttpBinarySerializer.SerializeObject(UserInfo.GUserInfo, true)); }
public string SetNewPassword(string AUserID, string AToken, string ANewPassword) { // make sure we are logged out. especially SYSADMIN could be logged in when a new user is created. Logout(); TVerificationResultCollection VerificationResult; bool Result = TMaintenanceWebConnector.SetNewPassword(AUserID, AToken, ANewPassword, out VerificationResult); return("{" + "\"AVerificationResult\": " + THttpBinarySerializer.SerializeObject(VerificationResult) + "," + "\"result\": " + THttpBinarySerializer.SerializeObject(Result) + "}"); }
private NameValueCollection ConvertParameters(SortedList <string, object> parameters) { NameValueCollection result = new NameValueCollection(); if (parameters == null) { return(result); } foreach (string param in parameters.Keys) { object o = parameters[param]; result.Add(param, THttpBinarySerializer.SerializeObject(o)); } return(result); }
public string PollClientTasks() { try { if (UserInfo.GUserInfo == null) { TLogging.Log("PollClientTasks: GUserInfo == null!"); return(THttpBinarySerializer.SerializeObject(false)); } return(THttpBinarySerializer.SerializeObject(DomainManager.CurrentClient.FPollClientTasks.PollClientTasks(), true)); } catch (Exception e) { TLogging.Log(e.ToString()); return(string.Empty); } }
public string SignUpSelfService(string AEmailAddress, string AFirstName, string ALastName, string APassword, string ALanguageCode, out TVerificationResultCollection AVerification) { AVerification = new TVerificationResultCollection(); try { TServerAdminWebConnector.LoginServerAdmin("SELFSERVICE"); bool Result = TMaintenanceWebConnector.SignUpSelfService(AEmailAddress, AFirstName, ALastName, APassword, ALanguageCode, out AVerification); Logout(); return("{" + "\"AVerification\": " + THttpBinarySerializer.SerializeObject(AVerification) + "," + "\"result\": " + THttpBinarySerializer.SerializeObject(Result) + "}"); } catch (Exception Exc) { TLogging.Log("An Exception occured during SignUpSelfService:" + Environment.NewLine + Exc.ToString()); throw; } }
/// throws an exception if the current user does not have enough permission to access the method; /// this uses a custom attribute associated with the method of the connector static public string CheckUserPermissionsForMethod(System.Type AConnectorType, string AMethodName, string AParameterTypes, Int32 ALedgerNumber = -1, bool ADontThrowException = false) { MethodInfo[] methods = AConnectorType.GetMethods(); MethodInfo MethodToTest = null; AParameterTypes = AParameterTypes.Replace("[]", ".ARRAY"); foreach (MethodInfo method in methods) { if (method.Name == AMethodName) { string ParameterTypes = ";"; ParameterInfo[] Parameters = method.GetParameters(); foreach (ParameterInfo Parameter in Parameters) { string ParameterName = Parameter.ParameterType.ToString().Replace("&", ""); ParameterName = ParameterName.Replace("System.Collections.Generic.Dictionary`2", "DICTIONARY"); ParameterName = ParameterName.Replace("Ict.Common.", string.Empty); ParameterName = ParameterName.Replace("Ict.Petra.Shared.MCommon.", string.Empty); ParameterName = ParameterName.Replace("System.", string.Empty); if (ParameterName.Contains(".")) { ParameterName = ParameterName.Substring(ParameterName.LastIndexOf(".") + 1); } ParameterName = ParameterName.Replace("`1", string.Empty); ParameterName = ParameterName.Replace("`2", string.Empty); ParameterName = ParameterName.Replace("Boolean", "bool"); ParameterName = ParameterName.Replace("Int32", "int"); ParameterName = ParameterName.Replace("Int64", "long"); ParameterName = ParameterName.Replace("[]", ".Array"); ParameterTypes += ParameterName + ";"; } ParameterTypes = ParameterTypes.ToUpper(); if (ParameterTypes == AParameterTypes) { MethodToTest = method; break; } } } if (MethodToTest != null) { System.Object[] attributes = MethodToTest.GetCustomAttributes(typeof(RequireModulePermissionAttribute), false); if ((attributes != null) && (attributes.Length > 0)) { RequireModulePermissionAttribute requiredModules = (RequireModulePermissionAttribute)attributes[0]; string moduleExpression = requiredModules.RequiredModulesExpression.ToUpper(); if (moduleExpression == "NONE") { return("OK"); } // authenticated user if (moduleExpression == "USER") { if (UserInfo.GetUserInfo() != null && UserInfo.GetUserInfo().UserID != null) { return("OK"); } } try { TSecurityChecks.CheckUserModulePermissions(moduleExpression); if (ALedgerNumber != -1) { TSecurityChecks.CheckUserModulePermissions(SharedConstants.LEDGER_MODULESTRING + ALedgerNumber.ToString("0000")); } } catch (ESecurityModuleAccessDeniedException Exc) { string msg = String.Format(Catalog.GetString( "Module access permission was violated for method '{0}' in Connector class '{1}': Required Module access permission: {2}, UserName: {3}"), AMethodName, AConnectorType, Exc.Module, Exc.UserName); TLogging.Log(msg); Exc.Context = AMethodName + " [raised by ModuleAccessManager]"; if (ADontThrowException) { TVerificationResultCollection VerificationResult = new TVerificationResultCollection(); VerificationResult.Add(new TVerificationResult("error", msg, "", "forms.NotEnoughPermissions", TResultSeverity.Resv_Critical)); return("{" + "\"AVerificationResult\": " + THttpBinarySerializer.SerializeObject(VerificationResult) + "," + "\"result\": false}"); } throw; } catch (ArgumentException argException) { throw new EOPAppException("Problem with ModulePermissions, " + argException.Message + ": '" + moduleExpression + "' for " + AConnectorType.ToString() + "." + AMethodName + "()", argException); } return("OK"); } } // TODO: resolve module permission from namespace? throw new EOPAppException( "Missing definition of access permission for method " + AMethodName + " in Connector class " + AConnectorType); }