public int StartImpersonation(string impersonatingUserLogin, string userLoginBeingImpersonated) { int result = -1; if (!_settings.IsImpersonationEnabled) { return(result); //nothing to do } //create activity entry for impersonatedUserLogin creation var dataset = _applicationSession.CreateDataSet(); var proxyUserGeneric = dataset.CreateGenericWithFields("user", "objid"); proxyUserGeneric.Filter(f => f.Equals("login_name", impersonatingUserLogin)); var proxiedUserGeneric = dataset.CreateGenericWithFields("user", "objid"); proxiedUserGeneric.Filter(f => f.Equals("login_name", userLoginBeingImpersonated)); var proxiedEmployeeGeneric = proxiedUserGeneric.TraverseWithFields("user2employee", "allow_proxy"); dataset.Query(proxyUserGeneric, proxiedUserGeneric); if (proxyUserGeneric.Count < 1) { throw new ArgumentException("The impersonating user {0} does not exist.".ToFormat(impersonatingUserLogin), "impersonatingUserLogin"); } if (proxiedUserGeneric.Count < 1) { throw new ArgumentException("The user being impersonated {0} does not exist.".ToFormat(userLoginBeingImpersonated), "userLoginBeingImpersonated"); } if (proxiedEmployeeGeneric.Rows[0].AsInt("allow_proxy") != 1) { throw new ArgumentException("The user being impersonated {0} does not allow others to impersonate them. The employee record for this user must have allow_proxy set to 1.".ToFormat(userLoginBeingImpersonated), "userLoginBeingImpersonated"); } cancelImpersonationFor(impersonatingUserLogin); _logger.LogDebug("Setting up user {0} as an impersonator of user {1}.".ToFormat(userLoginBeingImpersonated, impersonatingUserLogin)); //create act entry for impersonatedUserLogin creation result = CreateActEntry(impersonatingUserLogin, 94002, "Impersonate " + userLoginBeingImpersonated); createImpersonationFor(impersonatingUserLogin, userLoginBeingImpersonated); return(result); }
public IEnumerable <HistoryItem> Build(WorkflowObject workflowObject, Filter actEntryFilter) { var clarifyDataSet = _session.CreateDataSet(); var workflowObjectInfo = WorkflowObjectInfo.GetObjectInfo(workflowObject.Type); var workflowGeneric = clarifyDataSet.CreateGenericWithFields(workflowObjectInfo.ObjectName); workflowGeneric.AppendFilter(workflowObjectInfo.IDFieldName, StringOps.Equals, workflowObject.Id); var inverseActivityRelation = workflowObjectInfo.ActivityRelation; var activityRelation = _schemaCache.GetRelation("act_entry", inverseActivityRelation).InverseRelation; var actEntryGeneric = workflowGeneric.Traverse(activityRelation.Name); actEntryGeneric.AppendSort("entry_time", false); if (actEntryFilter != null) { actEntryGeneric.Filter.AddFilter(actEntryFilter); } var templateDictionary = _templatePolicyConfiguration.RenderPolicies(workflowObject); //query generic hierarchy and while using act entry templates transform the results into HistoryItems var assembler = _container.With(templateDictionary).With(workflowObject).GetInstance <HistoryItemAssembler>(); return(assembler.Assemble(actEntryGeneric)); }
public SDKUser GetUser(string username) { var impersonatedLogin = _userImpersonationService.GetImpersonatedLoginFor(username); var login = username; string impersonatingLogin = null; if (impersonatedLogin != null) { _logger.LogDebug("Proxied user: setting {0} as the authenticated user being proxied by {1}", impersonatedLogin, username); login = impersonatedLogin; impersonatingLogin = username; } var dataSet = _session.CreateDataSet(); var userGeneric = dataSet.CreateGenericWithFields("user", "login_name"); userGeneric.Filter.AddFilter(FilterType.Equals("login_name", login)); var employeeGeneric = userGeneric.TraverseWithFields("user2employee", "work_group", "first_name", "last_name"); var privClassGeneric = userGeneric.TraverseWithFields("user_access2privclass", "class_name"); var siteGeneric = employeeGeneric.TraverseWithFields("supp_person_off2site", "name"); var addressGeneric = siteGeneric.TraverseWithFields("cust_primaddr2address"); var timeZoneGeneric = addressGeneric.TraverseWithFields("address2time_zone", "name"); var queueGeneric = userGeneric.Traverse("user_assigned2queue"); queueGeneric.DataFields.Add("title"); userGeneric.Query(); if (userGeneric.Count < 1) { _logger.LogWarn("Could not find user {0}.", username); return(null); } var employeeRow = employeeGeneric.DataRows().First(); var privClassRow = privClassGeneric.DataRows().First(); var siteRow = siteGeneric.DataRows().First(); var queues = findQueues(queueGeneric); var timezone = findTimezone(timeZoneGeneric, username); return(new SDKUser { FirstName = employeeRow.AsString("first_name"), LastName = employeeRow.AsString("last_name"), SiteName = siteRow.AsString("name"), Workgroup = employeeRow.AsString("work_group"), PrivClass = privClassRow.AsString("class_name"), Login = userGeneric.Rows[0].AsString("login_name"), ImpersonatingLogin = impersonatingLogin, Queues = queues, Timezone = timezone }); }
public IAuthenticationToken RetrieveByToken(string token) { var dataSet = _session.CreateDataSet(); var userGeneric = dataSet.CreateGeneric("user"); userGeneric.DataFields.Add("login_name"); userGeneric.Filter(f => f.Equals("x_authtoken", token)); userGeneric.Query(); if (userGeneric.Count < 1) { _logger.LogDebug("No user for token {0} was found.".ToFormat(token)); return(null); } var username = userGeneric.DataRows().First().AsString("login_name"); _logger.LogDebug("Found user {0} for token {1}.".ToFormat(username, token)); return(new AuthenticationToken { Token = token, Username = username }); }
public GbstListsModel Execute(GbstListsRequest request) { var dataSet = _session.CreateDataSet(); var listGeneric = dataSet.CreateGeneric("gbst_lst"); listGeneric.DataFields.Add("title"); listGeneric.AppendSort("title", true); listGeneric.Query(); var lists = listGeneric.DataRows().Select(s => s.AsString("title")).ToArray(); return(new GbstListsModel { Lists = lists }); }
public SDKUser GetUser(string username) { var dataSet = _session.CreateDataSet(); var userGeneric = dataSet.CreateGeneric("user"); userGeneric.Filter.AddFilter(FilterType.Equals("login_name", username)); var employeeGeneric = userGeneric.TraverseWithFields("user2employee", "work_group", "first_name", "last_name"); var siteGeneric = employeeGeneric.TraverseWithFields("supp_person_off2site"); var addressGeneric = siteGeneric.TraverseWithFields("cust_primaddr2address"); var timeZoneGeneric = addressGeneric.TraverseWithFields("address2time_zone", "name"); var queueGeneric = userGeneric.Traverse("user_assigned2queue"); queueGeneric.DataFields.Add("title"); userGeneric.Query(); if (userGeneric.Count < 1) { _logger.LogWarn("Could not find user {0}.", username); return(null); } var employeeRow = employeeGeneric.DataRows().First(); var queues = findQueues(queueGeneric); var timezone = findTimezone(timeZoneGeneric, username); return(new SDKUser { FirstName = employeeRow.AsString("first_name"), LastName = employeeRow.AsString("last_name"), Workgroup = employeeRow.AsString("work_group"), Login = username, Queues = queues, Timezone = timezone }); }
public string UserValidator(string username) { var dataset = _session.CreateDataSet(); var emplViewGeneric = dataset.CreateGenericWithFields("empl_user", "login_name"); emplViewGeneric.Filter(f => f.And(f.Equals("status", 1), f.Equals("windows_login", username))); emplViewGeneric.Query(); if (emplViewGeneric.Count < 1) { throw new AuthenticationException("There is no employee whose Windows login name maps to {0}.".ToFormat(username)); } if (emplViewGeneric.Count > 1) { var names = emplViewGeneric.DataRows().Select(r => r.AsString("login_name")).ToArray(); _logger.LogError("There is more than one employee whose Windows login name maps to the user {0}. Using the first one of : {1}".ToFormat(username, String.Join(",", names))); } var clarifyUserName = emplViewGeneric.Rows[0].AsString("login_name"); _logger.LogDebug("Windows user {0} mapped to Clarify user {1}.", username, clarifyUserName); return(clarifyUserName); }