How to configure the domain password expiration policy in the Microsoft Active Directory

The Microsoft Active Directory is a great system to manage the security of servers and workstations. One of the fundamental security tools is the password expiration policy.

To set the password expiration policy in an Active Directory domain follow the steps below

  • Remote desktop into the domain controller
  • Start the Active Directory Users and Computers snap in
  • Right click the root domain name and select Properties
  • Select the Group Policy tab
  • In the middle select the Default Domain Policy Group Policy Object Link
  • Click the Edit button
  • On the left side expand Computer Configuration > Windows Settings > Security Settings > Account Policies
  • Select the Password Policy and Account Lockout Policy keys to set the desired values

active directory password policy

 

Warning!

All new and existing user accounts will inherit these settings, and the password of existing user accounts will immediately expire where the “Password never expires” option is not set.

Display deleted items in the Microsoft Visual Studio Source Control Explorer

When you delete a file or folder in TFS by default it is no longer displayed in the Source Control Explorer. To be able to “undelete” a file or folder enable the visibility of deleted items in Microsoft Visual Studio.

To see deleted items in the Source Control Explorer

  • Start Visual Studio
  • In the Tools menu select Options
  • On the left side expand Source Control
  • On the left side select Visual Studio Team Foundation Server
  • On the right side check Show deleted items in the Source Control Explorer
  • Click OK to save your changes

visual studio tfs show deleted items in source control explorer

To “undelete” a file or folder

  • Start Microsoft Visual Studio
  • Open the Source Control Explorer window
    • In the View menu select Other Windows
    • In the list select Source Control Explorer

In the Source Control Explorer window navigate to the location of the deleted item. Deleted files and folders are displayed in gray with a special icons.

visual studio tfs deleted folders in source control explorer

  •  Right click the item and select Undelete

 

Insert multiple rows into a Microsoft SQL Server database

There is a great way to insert multiple rows into a Microsoft SQL Server database in one statement. This notation has multiple advantages: simplicity and the grouping of multiple instructions into one transaction.

INSERT MyTable (name, description)
VALUES
('John', 'Manager')
,('Bill', 'Truck driver')

Script from Ernie Cruz

The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine. (System.Data)

When you try to import Excel 2007 or later “.xlsx” files into an SQL Server 2008 database you may get the following error mesage :

The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine. (System.Data)

sql server 2008 import excel xlsx

 

To solve this problem install the appropriate version of the Microsoft Access Database Engine.

 

On 32 bit Windows

On the 32 bit version of Windows Server 2003 download and install the 32 bit version of Microsoft Access Database Engine 2010 Redistributable from

http://www.microsoft.com/en-us/download/details.aspx?id=13255

 

On 64 bit Windows

On the 64 bit versions of Windows 7 and  Windows Server 2008 download and install the 64 bit version of

Microsoft Access Database Engine 2010 Redistributable from

http://www.microsoft.com/en-us/download/details.aspx?id=13255

and the

2007 Office System Driver: Data Connectivity Components from

http://www.microsoft.com/download/en/details.aspx?id=23734

 

You may also have to execute the following lines in the SQL Server Management Studio

  • Open a new query window
  • Select the master database
  • Execute the following lines

sp_configure ‘show advanced options’, 1;
RECONFIGURE;
sp_configure ‘Ad Hoc Distributed Queries’, 1;
RECONFIGURE;
GO

 

Why do we need to install the old 32 bit driver on the 64 bit operating system?

SQL Server Management Studio is a 32 bit application, most likely it can only use the 32 bit driver on the 64 bit operating system.

If you try to install the 32 bit version of the newer Microsoft Access Database Engine 2010 Redistributable and you already have the 64 bit version of Microsoft Office installed on your 64 bit computer you will get the following error message:

“You cannot install the 32-bit version of Microsoft Access Database Engine 2010 because you currently have 64-bit Office products installed. If you want to install 32-bit Microsoft Access Database Engine 2010, you will first need to remove the 64-bit installation of Office products. After uninstalling the following product(s), rerun setup in order to install 32-bit version of Microsoft Access Database Engine 2010: …”

sql server 2008 import excel xlsx 32 bit access database engine 64 bit office

 

The old 32 bit 2007 Office System Driver can be installed even if the 64 bit version of Microsoft Office 2013 is installed on the machine.

 

How to open SQL files in Visual Studio 2012

The default installation of Visual Studio 2012 cannot open SQL documents when you double click on them in Source Control Explorer.  To be able to do that you have to install the

SQL Server Data Tools  for Visual Studio 2012

For more information visit http://msdn.microsoft.com/en-US/data/tools.aspx

How to record two instruments simultaneously with Garage Band

My son and his friend wanted to record as they play together on a bass and an electric guitar.

To record two instruments simultaneously in Garage Band you need special hardware to connect both to the computer. You can buy a USB Recording Interface for a few hundred dollars, or you can make one for $13 plus tax.

All you need is a computer, two electric instruments or microphones, and a simple audio cable.

P1090545

 

In this example we will connect a bass and an electric guitar to a Macintosh computer and record them simultaneously with Garage Band. Computers usually have only one microphone input connector, so you can only connect one instrument or microphone at a time. But these audio inputs have two channels (left and right), so the sound card can record two mono audio signals simultaneously. Basses, electric guitars and most microphones produce mono (one channel) signals, so we can connect one of them to the left input and the other to the right input of the computer. To connect two audio sources to the computer simultaneously you need a special audio cable with two mono 1/4″ phone female jacks on one end and a 1/8″ (3.5mm) stereo male plug on the other.

P1090539

One 1/4″ phone female jack has to be connected to the left channel, the other to the right channel of the cable. If you cannot find a cable ready made in the stores you can make one yourself.

 

Make you own recording interface

You need some tools, that you can also buy at RadioShack.

P1090538

You need long-nose pliers, diagonal cutters, soldering iron and solder.

Buy

  • one 3ft (91 cm) audio Y-cable with 1/8″ (3.5mm) stereo male plug on one end and dual RCA (Phono) male plugs on the other. (RadioShack catalog number 42-494)

3_5mm to rca cable

 

  • one 2-pack 1/4″ mono female phone jacks (RadioShack catalog number 274-141)

phone jack

 

 

The 1/8″ stereo to dual RCA cable exposes the left and right channels of the audio input of the computer. The white plug is connected to the left channel, the red plug is connected to the right channel of the cable.

  • Cut off the RCA male phono plugs and solder the 1/4″ phone jacks to the end of the cables.

P1090541

 

  • To make the cable  more durable you can use shrink tubes on the phone jack end.

P1090540

 

Connect the instruments to the computer

 

  • Connect the bass to the left channel (where the white RCA plug was) and the electric guitar to the right channel (where the red RCA plug was) with standard guitar cables.
  • Insert  the 1/8″ stereo plug into the microphone input of the Macintosh

 

Record multiple instruments simultaneously

By default Garage Band can record only one track at a time, so we will enable multitrack recording in the Track menu of Garage Band below.

  • Start Garage Band
  • Create a new Voice project

01 project type

 

  • Set the name, tempo, signature and key of the project and click Create

02 project name

 

The new vocal project contains two tracks.

  • On the left side select the first track and on the right side set the instrument to Bass

03 track 1 instrument

 

  • On the right side set the desired bass effect

04 Track 1 effect

 

  • Set the input to Mono 1 (Built-in Input). This is the left channel.

05 Track 1 input

 

Turn on the track monitoring, so you can hear what you play.

  • On the right side select On (no feedback protection)

06 Track 1 monitor

 

  • To be able to simultaneously select multiple tracks for recording select Enable Multitrack Recording in the Track menu

07 enable multitrack recording

 

Set up the second track as Vocals and Guitar.

  • In Garage Band every track needs its own input, so you have to set the input of the second track to Mono 2 (Built-in Input). This is the right channel.

08 track 2 input

 

  • To arm both tracks for recording on the left side select the red recording buttons for both tracks

09 select both tracks for recording

Add if conditional statement to the Visual Studio pre-build and post-build events

There are times when you want to execute statements in the pre-build and post-build events of a Microsoft Visual Studio project when certain conditions met. In the next example we will copy the environment specific config file to the web application folder if the configuration is set to “Local”.

To edit the pre-buld and post-buld events

  • In the Visual Studio Solution Explorer right click the startup project
  • Select Properties
  • On the left side select the Build Events tab
  • To edit the script in a larger, resizable  window click the Edit Pre-Build or Edit Post-Build buttons

 

visual studio edit pre-build event

 

  • Enter the following lines into the event edit region:


if $(ConfigurationName) ==  Local (
attrib "$(ProjectDir)Web.config" -r
copy "$(ProjectDir)Config_2012\$(ConfigurationName).xml" "$(ProjectDir)Web.config"
)

The commands will be interpreted line-by-line the same way as a DOS batch file, so it is important to place the opening parenthesis “(” in the same line as the if statement.

How to add the Config folder to a Microsoft Visual Studio project even if the folder is not in the project directory

Corporations maintain multiple server environments for development, testing and production purposes.
All of these environments require specific settings to connect to the databases and other resources. When the build master builds the application for the specific environment the build process has to select the appropriate configuration and build it into the installer file for deployment.
It is a good practice to store these environment specific config files in a folder that also designates the Visual Studio version.

Console applications and Windows services

For console applications and Windows services place this folder into the “Source” folder.

visual studio add folder to project folder tree

 

In Microsoft Visual Studio you can add a folder to a project, but it will be created in the directory where the project file is located. To add a folder to a project when the folder is not in the project directory we have to manually edit the project file. In this example we will add a folder to our main project that contains the environment specific config files. The “Config_2012” folder is located in the “Source” folder outside of the “Project_2012” project directory.

The following steps will add the “Config_2012” folder to the project

  • Create the “Config_2012” folder in Windows Explorer
  • Add the environment specific config files to it
  • Add the folder to source control
  • Open the solution in Visual Studio
  • Right click the main project and select Unload Project
  • Right click the main project again and select Edit…
  • Add the following to the project file

<ItemGroup>
<None Include="..\Source\Config_2012\Dev.config">
<Link>Config_2012\Dev.config</Link>
</None>
<None Include="..\Source\Config_2012\Local.config">
<Link>Config_2012\Local.config</Link>
</None>
<None Include="..\Source\Config_2012\Prod.config">
<Link>Config_2012\Prod.config</Link>
</None>
<None Include="..\Source\Config_2012\QA.config">
<Link>Config_2012\QA.config</Link>
</None>
<None Include="..\Source\Config_2012\Staging.config">
<Link>Config_2012\Staging.config</Link>
</None>
<None Include="..\Source\Config_2012\UAT.config">
<Link>Config_2012\UAT.config</Link>
</None>
</ItemGroup>

 

  • Save the project file
  • Right click the main project file and select Reload Project

The “Config_2012” folder will appear in the Solution Explorer and the config files will be added as linked files.

visual studio add folder to project

Web applications and web services

For web applications and web services place the Config folder into the web application folder

web application folder structure config_2012 folder highlighted

To add the config folder and files to the web application

  • Open the web solution in Visual Studio
  • Select the web project
  • Click the Show All Files button on the Solution Explorer toolbar

visual studio show all files button

 

  • The Solution Explorer will display all files in the web application folder

web application solution explorer show all files config_2012 folder and files

 

  • Right click the Config_2012 folder  and select Include In Project

web application solution explorer show all files config_2012 folder include in project

 

  • Select all the config files in the Config_2012 folder
  • Right click the selection and select Properties

web application solution explorer show all files config_2012 folder files properties

 

  • Set the Build Action to None

web application file properties build action none

 

  • Click the Show All Files button on the Solution Explorer toolbar again to hide the excluded files

visual studio show all files button

 

Create a backup of a Microsoft SQL Server database to a location outside of the database server

The Microsoft SQL Server Management Studio 2008 user interface only allows you to create a backup of a database to one of the local drives of the database server.

To create a backup of a Microsoft SQL Server database to a location outside of the database server execute the following SQL script:


BACKUP DATABASE MyDatabase TO
DISK = N'\\MyNas\MyDatabase.bak'
WITH NOFORMAT, NOINIT, NAME = N'MyDatabase Database Backup', NOSKIP, STATS = 10
GO

Change the bold values to match your environment.