public static string AddSqlUsers() { using (PrincipalContext domain = new PrincipalContext(ContextType.Domain)) { List <string> badList = new List <string>(); List.ForEach(x => { if (UserPrincipal.FindByIdentity(domain, IdentityType.SamAccountName, x.LoginName) != null) { DataManage.CheckAddSqlUser(x.LoginName); } else { badList.Add(x.LoginName); } }); if (badList.Count > 0) { string names = ""; badList.ForEach(x => names += $", {x}"); return($"These Users are not in the Domain, cannot create SQL users for them: {names.Substring(2)}."); } } return(null); }
public static async Task <SyncResult> HandShakeAsync() { try { using (HttpClient client = new HttpClient()) { client.Init(); var query = HttpUtility.ParseQueryString(string.Empty); query["codeVer"] = MobileCommon.CurrentCodeVersion; query["dbVer"] = SystemInfo.Current.DataBaseVersion.ToString(); HttpResponseMessage response = await client.GetAsync($"api/SystemInfo?{query.ToString()}"); if (response.IsSuccessStatusCode) { SystemInfo serverInfo = await response.Content.ReadAsAsync <SystemInfo>(); if (serverInfo.CodeVersion != MobileCommon.CurrentCodeVersion) { return(new SyncResult { Successful = false, Task = "HandShake", Message = "Application version is not correct, please log out and restart." }); } if (serverInfo.DataBaseVersion != SystemInfo.Current.DataBaseVersion) { foreach (string script in serverInfo.PatchScript) { DataManage.RunPatch(script); } SystemInfo.UpdateDataBaseVersion(serverInfo.DataBaseVersion); } if (serverInfo.KeepDays != SystemInfo.Current.KeepDays) { SystemInfo.UpdateKeepDays(serverInfo.KeepDays); } return(new SyncResult { Successful = true, Task = "HandShake" }); } } return(new SyncResult { Successful = false, Task = "HandShake", Message = "Bad request to the Server." }); } catch (Exception e) { return(new SyncResult { Successful = false, Task = "HandShake", Message = e.Message }); } }