European Windows 2012 Hosting BLOG

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

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.



European WIndows Hosting :: Using Custom Fonts On Your Website With CSS

clock July 13, 2011 06:14 by author Scott

With CSS (Cascading Style Sheets) you can use custom fonts on your website. Normally your visitors can only see the fonts that are already installed on their computers. So if you use a font that is not installed on your website visitor’s computer then his or her browser will show some other font that is there on the computer. That’s why when you are defining a font for an element (such as <p>) you often specify multiple fonts so that if your preferred font is not available your CSS file should use the available alternatives.

Conventional way of using custom fonts for headings and logos etc. is creating the text in a graphic editor and then using the image file. From the perspective of SEO this is not appropriate; you must use text as much as possible.

Now there is a way around in CSS that lets you use custom fonts, downloadable fonts on your website. You can download the font of your preference, let’s say cool_font.ttf, and upload it to your remote server where your blog or website is hosted.

Then from within your CSS file (or wherever you are defining your styles) you have to refer to that custom font in the following manner:

@font-face {
      font-family: cool_font;
      src: url('cool_font.ttf');
}

After that you can use it just like a normal CSS declaration:


p.custom_font{
      font-family: cool_font; /* no .ttf */

}

This way you can use as many custom fonts as you feel like on your website.



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