WebInstaller.Base/VI.WebDesigner.Installer.Tasks/CreateUpdateUserTask.cs
Decompiler Source FileWebInstaller.Base.CreateUpdateUserTaskDecompiled Source
Interpretation
- Decompiled source file. Use method/event registrations and call-site extraction to connect back to DialogMethod, QBMEvent, and API layers.
Relations
- CallFunctionAsync: GetPwdPolicyUid at line 105
Typed Edges
- No typed edges extracted for this source.
References
- No direct source references extracted.
Referenced By
- No direct source references extracted.
C# source-derived context
Generated by pattern extraction from the decompiled C# source and decompile index. This is factual source evidence, not inferred behavior.
reads entity values writes entity values references DB/Dialog objects
Summary: classes CreateUpdateUserTask; methods GenerateUserName, CreateUser, DatabaseHasRequiredGroup, RunInternal, SetAuthString, AuthString; references DialogGroup, DialogUser, DialogUserInGroup; markers reads entity values, writes entity values, references DB/Dialog objects
Classes
CreateUpdateUserTaskDB/Dialog object references
OIM key/entity markers
UID_DialogUser UID_DialogGroupAPI/entity calls
CreateNew PutValue GetValue StartUnitOfWork Source CallFunctionAsync PutValueRegistrations / handlers
None extracted.
Complete Source
1using System;2using System.Collections;3using System.Collections.Generic;4using System.IO;5using System.Runtime.CompilerServices;6using System.Threading;7using VI.Base;8using VI.DB.Auth;9using VI.DB.Entities;10using VI.DB.Passwords;11using VI.DB.Sync;12using VI.Web.ConfigBase;13using VI.WebDesigner.Installer.DB;1415namespace VI.WebDesigner.Installer.Tasks;1617public class CreateUpdateUserTask : InstallationTask, ICreateUpdateUserTask, IInstallationTask18{19 private const string _UID_DIALOG_GROUP_FOR_UPDATE = "QBM-3855CE2CF105764290CC7F33688FA145";2021 [field: CompilerGenerated]22 public string LocalApplicationPath23 {24 [CompilerGenerated]25 get;26 [CompilerGenerated]27 set;28 }2930 [field: CompilerGenerated]31 public IDatabase Database32 {33 [CompilerGenerated]34 get;35 [CompilerGenerated]36 set;37 }3839 [field: CompilerGenerated]40 public string Url41 {42 [CompilerGenerated]43 get;44 [CompilerGenerated]45 set;46 }4748 [field: CompilerGenerated]49 public string UserNamePrefix50 {51 [CompilerGenerated]52 get;53 [CompilerGenerated]54 set;55 }5657 [field: CompilerGenerated]58 public bool UseAppSettings59 {60 [CompilerGenerated]61 get;62 [CompilerGenerated]63 set;64 }6566 [field: CompilerGenerated]67 public System.Collections.Generic.ICollection<string> UidGroupList68 {69 [CompilerGenerated]70 get;71 [CompilerGenerated]72 private set;73 }7475 public CreateUpdateUserTask()76 : base("WDI_CreateUpdateUser")77 {78 UserNamePrefix = "WebUpdate";79 List<string> obj = new List<string>();80 obj.Add("QBM-3855CE2CF105764290CC7F33688FA145");81 UidGroupList = (System.Collections.Generic.ICollection<string>)obj;82 }8384 private static string GenerateUserName(string prefix)85 {86 //IL_0006: Unknown result type (might be due to invalid IL or missing references)87 //IL_000b: Unknown result type (might be due to invalid IL or missing references)88 Guid val = Guid.NewGuid();89 string text = prefix + "_" + ((Guid)(ref val)).ToString("N");90 if (text.Length > 64)91 {92 text = text.Substring(0, 64);93 }94 return text;95 }9697 private string CreateUser(ISession session, string username)98 {99 //IL_002e: Unknown result type (might be due to invalid IL or missing references)100 //IL_0034: Unknown result type (might be due to invalid IL or missing references)101 //IL_004b: Unknown result type (might be due to invalid IL or missing references)102 using IUnitOfWork unitOfWork = session.StartUnitOfWork();103 IEntity entity = session.Source().CreateNew("DialogUser", EntityCreationType.Interactive);104 IPasswordManager mgr = session.Resolve<IPasswordManager>();105 string uidPasswordPolicy = (string)entity.CallFunctionAsync("GetPwdPolicyUid", "Password", p2: true).Result;106 string text = mgr.GetPolicyAsync(uidPasswordPolicy, CancellationToken.None).Result.CreatePassword().ToInsecure();107 entity.PutValue("UserName", username).PutValue("Password", text).PutValue("CustomRemarks", "Service account for the web application " + Url)108 .PutValue("PasswordNeverExpires", 1);109 unitOfWork.Put(entity);110 Log.Logger.Trace<string>("Trying to add dialog user '{0}' to dialog groups.", username);111 System.Collections.Generic.IEnumerator<string> enumerator = ((System.Collections.Generic.IEnumerable<string>)UidGroupList).GetEnumerator();112 try113 {114 while (((System.Collections.IEnumerator)enumerator).MoveNext())115 {116 string current = enumerator.Current;117 if (!DatabaseHasRequiredGroup(Database.Connection.Session, current))118 {119 Log.Logger.Trace<string>("Could not find dialog group '{0}' in databaase", current);120 continue;121 }122 Log.Logger.Trace("Adding user '{0}' to dialog group '{1}'.", username, current);123 IEntity entity2 = session.Source().CreateNew("DialogUserInGroup");124 entity2.PutValue("UID_DialogUser", entity.GetValue<string>("UID_DialogUser")).PutValue("UID_DialogGroup", current);125 unitOfWork.Put(entity2);126 }127 }128 finally129 {130 ((System.IDisposable)enumerator)?.Dispose();131 }132 unitOfWork.Commit();133 return text;134 }135136 private static bool DatabaseHasRequiredGroup(ISession session, string uidGroup)137 {138 return session.Source().Exists("DialogGroup", $"UID_DialogGroup = '{uidGroup}'");139 }140141 protected override void RunInternal()142 {143 Log.Logger.Debug("Creating random user name and password");144 string text = GenerateUserName(UserNamePrefix);145 Log.Logger.Debug<string>("Writing randomly created dialog user '{0}' to database", text);146 string password = CreateUser(Database.Connection.Session, text);147 Log.Logger.Debug("Writing connection string for randomly created dialog user to web.config");148 SetAuthString(AuthString(text, password));149 }150151 private void SetAuthString(string authString)152 {153 if (UseAppSettings)154 {155 AppSettingsHandler.SetValue(Path.Combine(LocalApplicationPath, "appSettings.json"), "ConnectionStrings:AutoUpdateUserAuth", authString);156 return;157 }158 string text = Path.Combine(LocalApplicationPath, "web.config");159 ConfigDocument configDocument = new ConfigDocument(text);160 configDocument.SetConnectionString("AutoUpdateUserAuth", authString);161 configDocument.SaveAsFile(text);162 }163164 private static string AuthString(string username, string password)165 {166 return ((object)new AuthProps("DialogUser")167 {168 new AuthProp("User", username),169 new AuthProp("Password", AuthPropType.Password, null, isMandatory: false, password)170 }).ToString();171 }172}173