private static void Logout() { try { SDKEnvironment.Logout(new Uri(ServerName)); } catch (Exception ex) { Program.Log.Error(null, ex); } try { if (scs != null) { scs.Abort(); scs.Dispose(); scs = null; } SDKEnvironment.RemoveAllServers(); } catch (Exception ex) { Program.Log.Error(null, ex); } }
private void LocalStartService() { Program.Logger.Log.Info("Start the service"); AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); var appprincipal = Thread.CurrentPrincipal as WindowsPrincipal; Program.Logger.Log.Info($"Is in administrators: {appprincipal.IsInRole("Administrators")}"); Program.Logger.Log.Info($"Windows identity: {WindowsIdentity.GetCurrent().Name}"); //Windows identity: NT AUTHORITY\SYSTEM LogSystemInfo(); WriteExecutingAssemblyVersion(); #if !DEBUG using (var impersonation = new Impersonation(BuiltinUser.NetworkService)) { #endif try { SDKEnvironment.Initialize(); // General initialize. Always required SDKEnvironment.RemoveAllServers(); TryConnectingToMilestoneServer(); } catch (Exception ex) { Program.Logger.Log.Error(null, ex); Program.Logger.Log.Info($"Windows identity: {WindowsIdentity.GetCurrent().Name}"); //Windows identity: NT AUTHORITY\NETWORK SERVICE } #if !DEBUG } #endif }