Monday, July 14, 2008

Who is connected to a server using Remote Desktop (command line command)

I was trying to connect to a machine, and then I get 'terminal server connection exceeded...' notification.
I was wondering if there is a way to find out who is connected to the machine so that i can send an email who is in 'Disconnected' mode or something.
I took the help of a network administrator, and he gave me one simple command that I ran from command line and it gave me the list of all sessions connected/disconnected to the machine.
Here you go:
C:\>qwinsta /server:urservername [press enter]

If you want to remove any instance/session, then run the following:
C:\>rwinsta /server:urservername ID# [press enter]

I like to mention it here though.

Read AppSettings Section from MyApp.dll.config

Its been long time, when I was struggling to read DLL Configuration file settings, and finally I found the solution. My app.config content is as :


<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler"/>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" ><section name="Lab3.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
<param name="File" value="C:\\AppConfig\\Log.txt"/>
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Composite"/>
<param name="DatePattern" value="yyyyMMdd"/>
<param name="MaxSizeRollBackups" value="10"/>
<param name="MaximumFileSize" value="50KB"/>
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d %-5p %c [%x] - %m%n"/>
</layout>
</appender>
<root>
<priority value="ALL"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
</log4net>
<appSettings>
<add key="UserName" value="MyUserName"/>
</appSettings>
<applicationSettings>
<MyApp.Properties.Settings>
<setting name="MyApp_SampleWS_Service1" serializeAs="String">
<value>http://localhost/SampleWebService/Service1.asmx</value>
</setting>
</Lab3.Properties.Settings>
</applicationSettings>
</configuration>


The assembly (MyApp.dll) is deployed in GAC, and the once compiled, I copied MyApp.dll.config from build folder to C:\AppConfig. This path is hardcoded in the code so that it can be picked up easily by the code.
This app.config has three major parts:
1. Log4Net - to write log details in a text file.
2. AppSettings
3. WebService Reference.

The piece of code that reads this config file from C:\AppConfig location:


ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = @"C:\AppConfig" + @"\MyApp.dll.config";
if (!File.Exists(fileMap.ExeConfigFilename))
{
logger.Info("File " + fileMap.ExeConfigFilename + " does not found.");
return;
}
assemblyConfig = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
AppSettingsSection appSettings = assemblyConfig.AppSettings;
logger.Info("App Settings found");
logger.Info("Key=UserName, Value=" + appSettings.Settings["UserName"].Value);
logger.Info("End of Information");

And two static variable declarations:

private static ILog logger = LogManager.GetLogger("Atul.Sample.ConfigSample");
private static Configuration assemblyConfig;

Add following line of code in AssemblyInfo.cs too to make log4net working correctly.

[assembly: log4net.Config.XmlConfigurator(ConfigFile = @"C:\AppConfig\MyApp.dll.config", Watch = true)]

Once again, make sure to copy 'MyApp.dll.config' in the C:\AppConfig location to make it work correctly.

Assumption is that your assembly is 'strongly named' as this is required for deployment in GAC.

Thursday, July 10, 2008

Installing MOSS 2007 on Windows Vista home edition (32Bit)

First of all, thanks to the authors of the website who published ways to install Windows Sharepoint Services 3.0 on Windows Vista Operating System.
The URL is
Hats off to the URL content authors!!!

I applied the steps mentioned in the URL. I have windows vista home premium 32bit operating system. However, URL doesn't claim that they have tested installation on Home Premium, however, I did. And I have installed it successfully.
I have SQL 2005 Developer Edition as well as SQL Express. Also have Visual Studio 2008 with .NET framework 2.0, 3.0 and 3.5.
Why I looked these options, because initially I wanted to run virtual PC 2005 or 2007 so that I can run virtual Hard Disk for MOSS 2007. As per the installation instructions, it doesn't support installation on Vista Home, and thanks to google that helped me to find bamboo solutions.
So, I downloaded the files per the URL instructions, and run the installation. While configuring the Sharepoint Services Database, I used SQL Server 2005 default named instance but configuration failed with some errors. Actually I deviated the installation per given the instructions in the URL. Once it failed, I followed the same instructions (installing it on SQL Express instead of regular SQL Default instance), and installation completed smoothly.
Now the challenge starts. I successfully start the Sharepoint services http://servername:8260/
First task is to create a web application, and created it successfully however, when I started the URL it failed with two different errors:
1. Internet Server Error - error on the web.config file.
2. Access Denied.
Please note that I opted Anonymous and Windows Authentication. However, Vista Home doesnt support Windows Authentication, it does support Basic Authentication. So once again I looked into the same URL for possible reasons how to make the website work, but in vain. People were talking about UAC (User Access Control) settings, though I did change it but in vain. So I reverted back all changes.

I tried all options:
1. Changing UAC Settings.
2. Changed Authentication mode in IIS 7.0. 'Basic Authentication' is enabled.











Even completed these steps didnt help me much, so was thinking that what exactly am I missing. And finally I get a breakthrough in the central administration itself.




















Click Save to save settings on Authentication Provider page.

Once I changed the option, it solved the problem and I was able to run my team site successfully.