European Windows 2012 Hosting BLOG

BLOG about Windows 2012 Hosting and SQL 2012 Hosting - Dedicated to European Windows Hosting Customer

European Windows 2008 Hosting :: Connect to FTP with Internet Explorer or Web Browser

clock January 9, 2012 16:40 by author Scott

There are many ways to connect by FTP to a host, we can use tools such as Filezilla, CoreFTP, or SmartFTP. But I would recommend to use Filezilla, very simpe, FREE, and easy to use. In this article, I will assume you cant connect or you don’t have a FTP client software. So, in this case you need to use Internet Explorer to connect it.

You can upload and delete files at your online server using Internet Explorer.

In order to connect by FTP with your browser, use the following address:

ftp://FtpUserID:[email protected]

For example, let’s assume the following:

FTP User: HostForLife
Password: googletest
Site: www.testFTP.com

The above information would use the following in the Internet Explorer Address bar:

ftp://HostForLife: [email protected]

However, if your FTP user used to connect is similar to [email protected], then you will have to URL encode it like this:

ftp:// FtpUserID%40YourDomainName.com:[email protected]

In the case above, it is important to note what the FTP username is:

FtpUserID%40YourDomainName.com

This address is URL-encoded and comes from [email protected] where @ has been substituted with %40, which is the ASCII code for @.

After visiting your website by using the above exampled address, Internet Explorer will open the site content in its window. Then from the “View” menu of Internet Explorer, you may select “Open FTP site in Windows Explorer” to edit, upload or delete the files at your web server.

Hope this tutorial will help you.



European Windows 2008 Hosting :: How to Solve Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

clock December 20, 2011 06:02 by author Scott

The Scenario:

Sometimes you may get a timeout issue looking something like this:

System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader()

The important part here is what is in the exception message:


System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

This may give you the impression that the server is down or something similar.

However, this is basically the SqlCommand.CommandTimeout property that has expired; the default timeout is 30 seconds.

See more at:

".NET Framework Class Library -> SqlCommand.CommandTimeout Property"

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout.aspx

Now, why would it time out?

There are 2 common reasons.

Long running tasks or uncommitted transactions. Let's show this by example.

In the first example, we emulate that the command execution takes a very long time to execute and return, for example there could be millions of rows being updated or for some other reason the execution takes a long time.

In the code I just call the SQL Server method "waitfor delay" that will pause the execution in SQL Server for 30 seconds, I then change the SqlCommand.CommandTimeout  from 30 seconds to 10 seconds so that we do not have to sit all day and wait for the exception. The code should be pretty self explanatory, just create a console application in Visual Studio.

Note that we connect to the trusty Northwind, if we would set the CommandTimeout to 60 seconds, then after 30 seconds we would get our Shippers table data back.

        static void Main(string[] args)
        {
            string cString = @"Data source=<your server>;Integrated Security=SSPI;Initial Catalog=Northwind";
            using (SqlConnection sc = new SqlConnection(cString))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("waitfor delay '00:00:30';select * from Shippers", sc);
                    cmd.CommandTimeout = 10;
                    Console.WriteLine("CommandTimeout: {0}", cmd.CommandTimeout);
                    sc.Open();
                    SqlDataReader r = cmd.ExecuteReader();
                    while (r.Read())
                        Console.WriteLine("{0} : {1}", r[0].ToString(), r[1].ToString());
                    sc.Close();
                }
                catch (SqlException se)
                {
                    Console.WriteLine(se);
                }
            }
        }

Run it, and after 10 seconds you will get the exception:

System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   ...

For the second reason, that there might be an uncommitted transaction, again we will use Northwind running the following the code, almost the same as above (only difference is that there is no call to “waitfor delay” in the SQL):

        static void Main(string[] args)
        {
            string cString = @"Data source=<your server>;Integrated Security=SSPI;Initial Catalog=Northwind";
            using (SqlConnection sc = new SqlConnection(cString))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("select * from Shippers", sc);
                    cmd.CommandTimeout = 10;
                    Console.WriteLine("CommandTimeout: {0}", cmd.CommandTimeout);
                    sc.Open();
                    SqlDataReader r = cmd.ExecuteReader();
                    while (r.Read())
                        Console.WriteLine("{0} : {1}", r[0].ToString(), r[1].ToString());
                    sc.Close();
                }
                catch (SqlException se)
                {
                    Console.WriteLine(se);
                }
            }
        }

Run this code and you should get the rows in the Shippers table returned.

Now, open Query Analyzer or Sql Server Management Studio and execute an uncommitted transaction on the Shippers table, like so:

use Northwind
go

begin tran
 update Shippers set CompanyName = 'aaaaa' where ShipperID = 1
--commit

(Note that the new value, in this case 'aaaaa' must be different compared to the existing one in order to see the problem)

Rerun the code above, and after 10 seconds you will, again, get the exception:

System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   ...

Go back to Query Analyzer or Sql Server Management Studio and commit the transaction, rerun code, and you will once again get the Shippers table data returned.

So to summarize, if the command you are executing is a long running one, adjust the CommandTimeout accordingly. If there are uncommitted transactions, you need to find what and where they are and change your code or your stored procedures accordingly.This is outside the scope of this blog, but one way to check for uncommitted transactions is to from QA or SSMS run the following:

dbcc opentran ('Northwind')

This will show if there are any blocked spids in the Northwind database which could be an indication of uncommitted transactions and queries that are blocked as a result of this.

It may seem obvious that a command times out if the command timeout expires. The background for this post is that I had a case where occasionally my customers’ users could not log in to their system. There was no clear pattern to this, and what happened when they tried to log in was that they got the exception above.  In the end it turned out that they had a page in the application that allowed the user to change employee information.

The problem was that when they made the change, they opened a transaction, however, they did not commit it until the user pressed a Save button. The interval between starting the edit of the employee information and the saving of it could be anything, either they made the change and saved immediately, or they made the change and went to lunch without saving.

During this time, all the logins would fail since the login functionality basically did a select from the employee table with the users’ login and password, which subsequently failed since the table was locked by the uncommitted transaction.

Once this was figured out, and the changes were made, all was well in login land.



How to Encrypt and Decrypt connectionString section in Web.config

clock November 22, 2011 06:01 by author Scott

Here is the source code to encrypt and decrypt <connectionString> section in Web.config using RSA Protected Configuration provider model.

Note that below source code is from class library file. It is quite feasible to edit the code and use within a button click event as you wish.

Hope you find it useful!!

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
//specific to configuration
using System.Configuration;
using System.Web.Configuration;
using System.Web.Security;
namespace WebUtils
{
/// <summary>
/// Contains methods for Encrypting and decrypting connectionStrings
/// section in web.config
/// current encryption configuration model is Rsa,
/// it is feasible to change this to DataProtectionConfigurationProvider
/// </summary>
/// <author>Raju Golla</author>
public class EncryptDecrypt
{
//Get Application path using HttpContext
public static string path = HttpContext.Current.
Request.ApplicationPath;
/// <summary>
/// Encrypt web.config connectionStrings
/// section using Rsa protected configuration
/// provider model
/// </summary>
#region Encrypt method
public static void EncryptConnString()
{
Configuration config = WebConfigurationManager.
OpenWebConfiguration(path);
ConfigurationSection section =
config.GetSection("connectionStrings");
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection
("RsaProtectedConfigurationProvider");
config.Save();
}
}
#endregion
/// <summary>
/// Decrypts connectionStrings section in
///web.config using Rsa provider model
/// </summary>
#region Decrypt method
public static void DecryptConnString()
{
Configuration config = WebConfigurationManager.
OpenWebConfiguration(path);
ConfigurationSection section =
config.GetSection("connectionStrings");
if (section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
config.Save();
}
}
#endregion
}
}

References:

http://msdn.microsoft.com/en-us/library/ms998280.aspx



European Windows 2008 R2 Hosting :: How to Enable Active Directory Recycle Bin Feature on Windows 2008 R2

clock November 4, 2011 06:07 by author Scott

Windows 2008 R2 has introduced a number of compelling features that would entice any Windows administrator to upgrade to, and the most welcomed feature in my own opinion would have to be the Active Directory Recycle Bin.  Previous to the R2 upgrade, system admins and the like would have had to rely on paid 3rd party software that would take care of accidental deletions of users or even worst organizational units.  Those who did not make the investment in 3rd party software would have had to rely on system state backups which is always a disruptive process in the event that you needed to perform an authoritative Active Directory restore.

Before we begin, we need to ensure that we have met the minimum requirements allowing you to enable the Active Recycle Bin.  In summary, your Domain Forest Functional Level needs to be at least Windows 2008 R2.  More information can be found in the following TechNet article;
http://technet.microsoft.com/tr-tr/library/dd379484(WS.10).aspx

Now that we have met those requirements, we need to run the following command on the AD Domain controller where the Schema Master Resides.  If you are not sure where the Schema Master role resides, follow the below TechNet article on How to view and transfer FSMO roles in Windows Server 2003.

On the Schema Master Domain Controller, run Start / Administrative Tools /  Active Directory Module for Windows PowerShell.

Type in the following command;

N.B replace yourdomain.com with your own Active Directory domain name

Enable-ADOptionalFeature –Identity ‘CN=Recycle Bin Feature,CN=Optional Features,CN=Directory Service,CN=Windows NT,CN=Services,CN=Configuration, DC=yourdomain,DC=com’ –Scope ForestOrConfigurationSet –Target ‘yourdomain.com’



You will get a warning which you will need to confirm stating that enabling the Recycle Bin Feature is irreversible.

That’s it!  The recycle bin will now begin capturing deletions of objects which will allow you to later restore them to their original or alternate location.  Now you might be asking, how do we actually perform a restore?  Well, I’m glad you asked, that’s the 2nd reason why you are reading this article right?!

Microsoft for some reason did not provide admins with a GUI in doing so, however there are FREE 3rd party tools that plug directly into the Recycle Bin feature that will provide you with an easy GUI for performing Active Directory object(s) restoration.  Now before delving into MY current tool of choice, the following article by Microsoft explains how it is done via the command line; Restore a Deleted Active Directory Object
http://technet.microsoft.com/tr-tr/library/dd379509(WS.10).aspx

My tool of choice (there are several out there) providing me with a graphical interface is PowerGUI in combination with their Active Directory Recycle Bin for PowerPack.  You can download these from the links below;

Download the latest PowerGUI from
http://powergui.org/downloads.jspa

Download the latest Active Directory Recycle Bin PowerPack from http://powergui.org/kbcategory.jspa?categoryID=46

Now that we have the relevant components, install PowerGUI and then import the AD Recycle Bin PowerPack via File / PowerPack Management / Import



Now as a test I have created a Test User account in Active Directory and then deleted the account a few minutes later.  Lo and behold when I refreshed the Active Directory Recycle Bin node within the PowerGUI Navigation tree, my Test User was listed in the results pane.



From the Actions menu, you can easily restore the user to either its original location or alternate location.  From the Actions menu you can also configure the recycle bin further via a GUI, and empty the recycle bin completely.



As you can see from the above, the Active Recycle Bin is a long awaited feature introduced with Windows 2008 R2 and with a front end like PowerGUI you can now easily and very quickly restore accidentally deleted Active Directory objects.  Now I wonder if Microsoft will incorporate their own graphical interface in the near future.



European Windows 2008 R2 Hosting :: How to Build a Windows Server 2008 R2 Domain Controller

clock October 22, 2011 06:47 by author Scott

This is great for developers, testers, and anyone looking to learn Active Directory or deploy to a small network.  If this is for a production deployment, you might want to bring in a professional to help you.  There are many other things to consider, like ‘hardening’ your server and setting up Group Policy.  Having an insecure or unprotected domain controller is inviting havoc on your network.

So without any further ado and in the immortal words of ‘Marv’, “Let’s get to it!”

In the Server Manager click on Add Roles.



Click next on the ‘Before You Begin’ screen if it shows.  On the next screen, ‘Select Server Roles’, check the box for Active Directory Domain Services.  After checking the box, you may receive a window that says you need to add required features, click the button marked Add Required Features.





Then back at the ‘Select Server Roles’ window, click Next.  Here you can do some reading if you’re unfamiliar with Active Directory.  There are links for an overview, installation instructions, and common configurations.  There’s also some notes that say it is advisable to have at least 2 domain controllers, that you’ll need a DNS server, that you’ll have to run DCPROMO.exe, and informs you that you’re also installing DFS (Distributed File System), and some replication services tied to DFS.

Click Next and you’ll see the ‘Confirm Installation Selections’ window.  Click the button marked Install.



The ‘Installation Progress’ window will appear letting you know what the system is doing.  After a few minutes the ‘Installation Results’ window will appear.  Click the link marked Close this wizard and launch the Active Directory Domain Services Installation Wizard (dcpromo.exe).



Another wizard will open, ‘Active Directory Domain Services Installation Wizard’.  Click Next



Read the note on the next screen titled ‘Operating System Compatibility’.  The link to the KB article 942564 underneath is (
http://go.microsoft.com/fwlink/?LinkId=104751).  Click Next. On the ‘Choose a Deployment Configuration’ screen, we’ll choose Create a new domain in a new forest for the purposes of this tutorial.  If you’re attempting to add a domain controller to an existing domain / forest, you would choose the ‘Existing Forest’ checkbox.  Click Next



Here’s where you input what you want your FQDN (Fully Qualified Domain Name) to be.  Then click Next.



The system will confirm that the FQDN is not in existence already on your network, then allow you to choose your Domain NetBIOS name.  After doing so, click Next.  The system will then confirm that NetBIOS name is not in use.



On the next screen, you select what you want your forest functional level to be.  You can choose: Windows Server 2003, 2008, or 2008 R2.  In this tutorial we’ll be setting the forest functional level to Windows Server 2008 R2.  If you’ll be connecting other DCs that are running Windows Server 2008 or 2003, then may will need to choose a compatible level.  Click Next.



Now we’ll install the DNS server.  Make sure that DNS server checkbox is checked, then click Next.  Domain controllers, DCs, require Domain Name Services.



Click Yes at the next window, which is warning you that delegation cannot be configured for the parent zone.  Don’t worry, there is no parent zone.  Accept the default locations for your Database, Log Files, and SYSVOL folders, or change them if you really like.  Click Next.



Input a password, twice, in the ‘Directory Services Restore Mode Administrator Password’ window.  Then click Next.  Review your selections and click Next.

The wizard will then install and configure Active Directory Domain Services and Directory Services on the DC.  Click Finish, and select to Restart.



Congratulations, you’ve just done the basic setup for an Active Directory Domain Controller, and DNS support services on Windows Server 2008 R2.  After the reboot, you can log into your server using the administrator account and password that was previously assigned to the local administrator account.  NOTE: the password that you were using, is now assigned as your domain admin.  It is advisable to make sure that password is STRONG.



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in