无法从 C# 执行 TekRadius CLI

Unable to execute TekRadius CLI from C#

TekRadius 是我想通过我的 ASP.NET 应用程序访问的 Radius 服务器。我首先尝试使用 C# 直接执行 TekRadius CLI。但它没有用。现在我正尝试通过 CMD 调用它来通过 C# 代码执行它,如下所示:

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C \"c:\Program Files (x86)\TekRADIUS LT\trclilt.exe\" -u " + username + " " + password;
process.StartInfo = startInfo;
process.Start();
string line = "";
while (!process.StandardError.EndOfStream)
{
    line = line + "\n" + process.StandardError.ReadLine();
}
File.WriteAllText(HttpContext.Current.Server.MapPath("~\error.txt"), line);

TekRadius 在直接通过 CLI 或 GUI 或通过 Visual Studio 的内部服务器执行时工作正常。但是在主服务器上,我的自定义错误日志 error.txt 显示此错误:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.UnauthorizedAccessException: Access to the path 'C:\Windows\TEMP\System.Data.SQLite.dll' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)
   at ????????????????????????????????????????.????????????????????????????????????????(String , String )
   at ????????????????????????????????????????.????????????????????????????????????????()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at ????????????????????????????????????????(String[] )

TekRadius CLI 使用 SQLLite 来存储其用户名和密码。我知道是 TekRadius 无法访问 'C:\Windows\TEMP\System.Data.SQLite.dll',而不是我的应用程序,因为我使用的是 SQL 服务器,而且我上面的 C# 代码没有尝试访问数据库。我正在使用 Windows Server 2012 R2,我也无法在 Windows 文件夹上设置新权限。请告诉我如何才能允许 TekRadius CLI 访问此位置?

终于在12小时后我自己解决了。解决方案是为 C:\Windows\Temp 文件夹中的 System.Data.SQLite.dll 完全控制 ISS_IUSRS。此外,对 c:\Program Files (x86)\TekRADIUS LT\trclilt.exe.

执行相同的操作