Question

I am running this code.

server.Open();
        //Console.WriteLine("----------------------------------------------------");
        //Console.WriteLine("Active users on {0}", machineName);
        foreach (ITerminalServicesSession session in server.GetSessions())
        {
            System.Security.Principal.NTAccount account = session.UserAccount;
            if (account != null)
            {
                if (session.ConnectionState == Cassia.ConnectionState.Active)
                {
                    ((TextBox)Page.FindControl("txt" + machineName.Substring(7))).Text += session.UserName + " idle " + session.IdleTime.TotalMinutes + " minutes" + "\r\n";
                }
            }
        }

It runs fine in console application but gives "No more data is available " error in asp.net page.

Était-ce utile?

La solution

I created a new Application Pool in IIS 7 and set its identity as my personal username instead of the default AppIdenitity. Then I assigned this new Application Pool to my ASP.NET web application in IIS. Issue fixed.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top