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.

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top