Added check if the software was started with admin rights.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Security.Principal;
|
||||
using System.Windows.Forms;
|
||||
using BizTalkPlatformManagementTool.Ui;
|
||||
|
||||
@@ -11,7 +12,36 @@ namespace BizTalkPlatformManagementTool
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
if (!IsRunningAsAdministrator())
|
||||
{
|
||||
MessageBox.Show(
|
||||
"BizTalk Platform Management Tool must be started with administrator rights.\r\n\r\n" +
|
||||
"Please close the application and start it again with 'Run as administrator'. " +
|
||||
"Without elevated rights, BizTalk WMI operations in root\\MicrosoftBizTalkServer will fail.",
|
||||
"Administrator Rights Required",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
|
||||
private static bool IsRunningAsAdministrator()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var identity = WindowsIdentity.GetCurrent())
|
||||
{
|
||||
var principal = new WindowsPrincipal(identity);
|
||||
return principal.IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user