C# 本地计算机和IIS列出rdp会话
我使用活动RDP会话视图创建ASP.NET应用程序 此代码在本地计算机上的Visual Studio中执行时成功返回会话,但在IIS上部署时,返回的列表为空,并且没有引发任何异常 C#控制台应用程序中的相同代码工作正常 有什么建议吗C# 本地计算机和IIS列出rdp会话,c#,asp.net,iis,C#,Asp.net,Iis,我使用活动RDP会话视图创建ASP.NET应用程序 此代码在本地计算机上的Visual Studio中执行时成功返回会话,但在IIS上部署时,返回的列表为空,并且没有引发任何异常 C#控制台应用程序中的相同代码工作正常 有什么建议吗 public static List<TerminalSessionData> ListSessions(string ServerName) { IntPtr server = IntPtr.Zero; List<Terminal
public static List<TerminalSessionData> ListSessions(string ServerName)
{
IntPtr server = IntPtr.Zero;
List<TerminalSessionData> ret = new List<TerminalSessionData>();
server = OpenServer(ServerName);
try
{
IntPtr ppSessionInfo = IntPtr.Zero;
Int32 count = 0;
Int32 retval = WTSEnumerateSessions(server, 0, 1, ref ppSessionInfo, ref count);
Int32 dataSize = Marshal.SizeOf(typeof(WTS_SESSION_INFO));
Int64 current = (int)ppSessionInfo;
if (retval != 0)
{
for (int i = 0; i < count; i++)
{
WTS_SESSION_INFO si = (WTS_SESSION_INFO)Marshal.PtrToStructure((System.IntPtr)current, typeof(WTS_SESSION_INFO));
current += dataSize;
ret.Add(new TerminalSessionData(si.SessionID, si.State, si.pWinStationName));
}
WTSFreeMemory(ppSessionInfo);
}
}catch(Exception ex)
{
throw ex;
}
finally
{
CloseServer(server);
}
return ret;
}
公共静态列表ListSessions(字符串服务器名)
{
IntPtr server=IntPtr.Zero;
List ret=新列表();
server=OpenServer(ServerName);
尝试
{
IntPtr ppSessionInfo=IntPtr.Zero;
Int32计数=0;
Int32 retval=WTSEnumerateSessions(服务器、0、1、引用ppSessionInfo、引用计数);
Int32 dataSize=Marshal.SizeOf(typeof(WTS_SESSION_INFO));
Int64当前=(int)ppSessionInfo;
如果(返回值!=0)
{
for(int i=0;i
我必须打开Personification并输入管理员登录名/密码,这是服务器上的返回值(
retval
)?你有适当的权限吗?如果临时以管理员权限运行站点会发生什么情况?IIS是以管理员权限打开的。仅以管理员权限运行IIS应用程序是不够的