Showing posts with label How to .... Show all posts
Showing posts with label How to .... Show all posts

Wednesday, July 13, 2011

Intelligent String Breaking - DVWP

There are situations like we want to show only a part of a text followed by three dots or a more link, which is straight forward using substring(). But if the requirement is to not to cut the last word in half, there is some additional work involved. Here is an XSLT template to substring without breaking words.

In here StringBreak template looping over the characters in a given string and look for the last space character within the given length. Here the looping starts from the needed size of the result string, which is CharLimit index of the given text and goes towards start until, find a space character (Actually the first space character from the searching location). Once found, it gets the index of that space character and substring from start to that character.

<!-- String Break Template -->
<xsl:template name="StringBreak">
<xsl:param name="text" />
<xsl:param name="count" />

<xsl:if test="string-length($text) &lt;= $count" >
<xsl:value-of select="$text"/>
</xsl:if>
<xsl:if test="string-length($text) &gt; $count" >
<xsl:if test="not($count &lt; 1)">
<xsl:choose>
<xsl:when test="substring($text, $count + 1, 1) = ' '">
<xsl:value-of select="substring($text, 1, $count)"/> ...
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="StringBreak">
<xsl:with-param name="count" select="$count - 1" />
<xsl:with-param name="text" select="$text" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:if>
</xsl:template>

<!--Define a variable called ‘CharLimit’, which is the size of the output -->
<xsl:variable name="CharLimit" select="'30'"></xsl:variable>

<!-- Call String Break Template -->
<xsl:call-template name="StringBreak">
<xsl:with-param name="text" select="@Title" />
<xsl:with-param name="count" select="$CharLimit" />
</xsl:call-template>

Wednesday, March 23, 2011

Customize Entity Framework Code Generation with T4 Templates

The ADO.NET Entity Framework enables developers to create data access applications by programming against a conceptual application model. In here the logical schema and its mapping with the physical schema is represented by an Entity Data Model (EDM). We can design our Entity Data Model by using Entity Data Model Designer or updating from a database. In both ways it auto generates the relevant code (ObjectContext and various EntityObject classes) in Model.designer.cs file and manual changes to this file may cause unexpected behavior in the application. Also manual changes will be overwritten if the code is regenerated.

But what if we want to do a change to the way file auto-generates? For example in order to XML serialize objects with populated property objects, you might want to remove [XmlIgnoreAttribute()] attribute from the generated code.

Here we can use T4 (Text Template Transformation Toolkit) templates to customize how the ObjectContext and entity classes are created. For the purpose we start with the default T4 Template and then modify it.

This is my simple model:



If we look at the auto generated code, we can see “[XmlIgnoreAttribute()]” as in the following code.

///
/// No Metadata Documentation available.
///

[XmlIgnoreAttribute()]
[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute("TestT4Model", "FK_Region_RegionType", "Region")]
public EntityCollection Regions
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection("TestT4Model.FK_Region_RegionType", "Region");
}
set
{
if ((value != null))
{
((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection("TestT4Model.FK_Region_RegionType", "Region", value);
}
}
}


Add a T4 Template to the Model:
We can add a T4 Template by Right Click -> Add Code Generation Item… or



By using Add New Item window and selecting ADO.NET EntityObject Generator type.


Then we will get a new item with the .tt extension. Now if we examine Model1.Designer.as file, we can see it is empty. Instead Model1.cs file under Model1.tt file has that generated code.



Now to change the code generation we need to modify Model1.tt template. If we open the Model1.tt file, we can see text which is inside <# #> and text which is not inside <# #> brackets. The text which is inside <# #> is the code to be executed. Text which is not inside the angle brackets will simply be written out to the file. Here is a part of the Model1.tt content.

<# //////// //////// Write Navigation Properties. //////// region.Begin(GetResourceString("Template_RegionNavigationProperties")); foreach (NavigationProperty navProperty in entity.NavigationProperties.Where(n => n.DeclaringType == entity))
{
VerifyGetterAndSetterAccessibilityCompatability(navProperty);
#>

///
/// <#=SummaryComment(navProperty)#>
///
<#=LongDescriptionCommentElement(navProperty, region.CurrentIndentLevel)#>
[XmlIgnoreAttribute()]
[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute("<#=navProperty.RelationshipType.NamespaceName#>", "<#=navProperty.RelationshipType.Name#>", "<#=navProperty.ToEndMember.Name#>")]
<# if (navProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many) { #>

Here if we search for “[XmlIgnoreAttribute()]” attribute we can find it outside the <# #> brackets. Which means it will simply be written out to the file. So I can find and delete those “[XmlIgnoreAttribute()]” attributes where necessary and modified file will be like follows.

<# //////// //////// Write Navigation Properties. //////// region.Begin(GetResourceString("Template_RegionNavigationProperties")); foreach (NavigationProperty navProperty in entity.NavigationProperties.Where(n => n.DeclaringType == entity))
{
VerifyGetterAndSetterAccessibilityCompatability(navProperty);
#>

///
/// <#=SummaryComment(navProperty)#>
///
<#=LongDescriptionCommentElement(navProperty, region.CurrentIndentLevel)#>
[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute("<#=navProperty.RelationshipType.NamespaceName#>", "<#=navProperty.RelationshipType.Name#>", "<#=navProperty.ToEndMember.Name#>")]
<# if (navProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many) { #>

Then when we save this template, code generation will be happen automatically and “[XmlIgnoreAttribute()]” is not there in the generated code in Model1.cs.

///
/// No Metadata Documentation available.
///

[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute("TestT4Model", "FK_Region_RegionType", "RegionType")]
public RegionType RegionType
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference("TestT4Model.FK_Region_RegionType", "RegionType").Value;
}
set
{
((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference("TestT4Model.FK_Region_RegionType", "RegionType").Value = value;
}
}

Wednesday, March 9, 2011

IIS URL Rewrite Module - Redirect HTTP to HTTPS with IIS 7

Using IIS URL Rewrite Module, Web administrators can easily set up rules to define URL rewriting behavior based on HTTP headers, HTTP response or request headers, IIS server variables, and programmatic rules. Here the main purpose is to implement URLs that are easier for users to remember and easier for search engines to find.

In addition, we can define rules to force SSL on selected pages of a Website which is hosted in IIS 7. First of all we need to install Microsoft URL Rewrite Module in IIs. Then we need to install SSL certificate, create HTTPS bindings to our IIS Web site and assign the certificate. Then select our Web site under Sites node and make sure "Require SSL" is NOT checked under SSL Settings.

After that we have to add following config section to the web.config file in the Web site root directory.
















In here a rewrite rule is defined by specifying a pattern to use for matching the URL string and an action to perform if a pattern is matched. In addition an optional condition is also specified which will be checked in the matching step.

Thanks Carlos Redondo for your suggestion!

Monday, March 7, 2011

Skill Based Search in Lync 2010

As we search in Lync for people in the organization by name, we can configure it to enable search for people by skill set. When I was searching for ways on extending Lync Client, I came across this built-in feature called “Skill Based Search” on Lync 2010. When we configure Lync Skill Search, users can search SharePoint Server 2010 My Site pages for names, keywords, or specific skills. We can also add a link at the bottom of the Lync search results window that opens the search results in SharePoint.

(My Sites in SharePoint 2010 is a personal site for individual users that gives a central location to manage and store documents, content, newsfeeds, links, and contacts. Also My Site contains a section defining and sharing profile information and content with other users in the organization. My Sites give users rich social networking and collaboration features enabling easily share information about themselves and their work. This article describes how to set up My Sites in Microsoft SharePoint Server 2010.)

In order to configure Lync 2010 Skill Search, "New-CsClientPolicy" or "Set-CsClientPolicy" commands are used with "SPSearchExternalURL" and "SPSearchInternalURL" parameters to configure a Client Policy. Then using "Grant-CsClientPolicy" we can assign the new policy/policies to users.

Also using "SPSearchCenterExternalURL" and "SPSearchCenterInternalURL" parameters we can add a link to the bottom of the Skill Search results that says, “View results in SharePoint…”. Users can use this link to refine search results by using the advanced search capabilities of SharePoint Server.

Link
Commands to run in Power Shell to enable the Skill based search URLs;
Set-CSClientPolicy -SPSearchInternalURL http://<server>/_vti_bin/search.asmx
Set-CSClientPolicy -SPSearchExternalURL http://<server>/_vti_bin/search.asmx
Set-CSClientPolicy -SPSearchCenterInternalURL http://<server>/SearchCenter/Pages/PeopleResults.aspx
Set-CSClientPolicy -SPSearchCenterExternalURL http://<server>/SearchCenter/Pages/PeopleResults.aspx

Parameters;
SPSearchCenterExternalURL: This is for users logging on from outside the organization’s firewall. This URL will appear at the bottom of keyword search results giving the user the opportunity to conduct searches using the search capabilities of SharePoint.
SPSearchCenterInternalURL: URL for users logging on from inside the organization’s firewall to conduct searches using the search capabilities of SharePoint.
SPSearchExternalURL: Lync 2010 will use this SharePoint site when a user who has accessed the system from outside the organization’s firewall conducts a keyword search.
SPSearchInternalURL: Will use the SharePoint site located at this URL when a user who has logged on from inside the organization’s firewall conducts a keyword search.

For more information on Enabling Skill Search in Lync 2010;
http://blogs.catapultsystems.com/tharrington/archive/2010/11/15/enabling-skill-search-in-lync-2010.aspx
For more information on getting this to work externally via Threat Management Gateway;
http://techblurt.com/2011/02/22/lync-2010-people-search-with-sharepoint-2010-and-tmg/
For more information on Lync 2010 Integration;
http://technet.microsoft.com/en-us/library/gg398806.aspx

Friday, February 4, 2011

How to Configure SSL on Particular Pages of an IIS 7 Website

Today I wanted to force SSL on selected pages of a Website which is hosted in IIS 7. I could find lot of articles in the Web describing how to configure SSL for the whole website. But I needed it for few specific pages only. This is the way finally I achieved my goal.

Using Server Certificates feature of the IIS server install my certificate.
Create a SSL Binding for my Web site and make sure all the pages are accessible via both HTTP and HTTPS.

Then in order to force SSL on selected pages I used following method on Page_Load event of those pages. In here I used Request.ServerVariables collection to see if the protocol being used is HTTP or HTTPS.


protected void Page_Load(object sender, EventArgs e)
{
// Redirect to the corresponding secure page.
RedirectToSecurePage();
}




///
/// Redirect to the corresponding secure page.
/// Assumption: IIS web site is configured in port 80.
///

public void RedirectToSecurePage()
{
var httpsMode = string.Empty;
var serverName = string.Empty;
var url = string.Empty;

for (var i = 0; i < Request.ServerVariables.Keys.Count; i++)
{
var key = Request.ServerVariables.Keys[i];
if (key.Equals("HTTPS"))
{
httpsMode = Request.ServerVariables[key];
}
else if (key.Equals("SERVER_NAME"))
{
serverName = Request.ServerVariables[key];
}
else if (key.Equals("URL"))
{
url = Request.ServerVariables[key];
}
}
if (httpsMode.Equals("off"))
{
Response.Redirect(string.Concat("https://", serverName, url));
}
}


So when each page is browsed, the code that is contained in the Page_Load event detects if HTTP is used. If HTTP is used, the browser will be redirected to the same page by using HTTPS.

Comments are really appreciated on how to handle this scenario in another (better) way...


Tuesday, December 21, 2010

Logging using Enterprise Library - Change the log file Name and Path to the My Documents folder

When using Enterprise Library Logging Application Block as the logging tool, here is how to change the file path and the name of the trace file during run time. What I'm doing here is update the listener's "filename" (loggingConfiguration->listeners) in the App.config.


using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;

/// <summary>
/// Change the log file path and name.
/// </summary>
public void SetTraceLogPath()
{
// Log file path.
string logFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
@"\MyLogs\" + DateTime.Now.ToString("yyyy-MM-dd") + ".log";

ConfigurationFileMap objConfigPath = new ConfigurationFileMap();

// App config file path.
string appPath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
objConfigPath.MachineConfigFilename = appPath;

Configuration entLibConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

LoggingSettings loggingSettings = (LoggingSettings)entLibConfig.GetSection(LoggingSettings.SectionName);

TraceListenerData traceListenerData = loggingSettings.TraceListeners.Get("FlatFile TraceListener");
FlatFileTraceListenerData objFlatFileTraceListenerData = traceListenerData as FlatFileTraceListenerData;

objFlatFileTraceListenerData.FileName = logFilePath;

entLibConfig.Save();
}

Then I can use following method to log exceptions to the specified path. In this case log file will be created in the My Documents folder of the current user.


///<summary>
/// Log exceptions.
///</summary>
public void LogException(Exception ex)
{
string strMessage = string.Empty;
strMessage += ex.Message + "\r\n";
strMessage += ex.StackTrace;

LogEntry le = new LogEntry();
le.Categories.Add(Constants.LoggingCategory.Exception.ToString());
le.Severity = TraceEventType.Error;
le.Message = strMessage;
le.Title = ex.Message;
le.Priority = 1;

Logger.Write(le);
}

This is how my app.Config file looks. There should be a
FlatFileTraceListener configured as follows.

  <configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add fileName="trace.log" header="----------------------------------------"
footer="----------------------------------------" formatter=""
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="FlatFile TraceListener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="FlatFile TraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors &amp; Warnings">
<listeners>
<add name="FlatFile TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>

Wednesday, November 3, 2010

How to Get Row Count of All Tables - SQL Server

For this purpose doing a rowcount for each table will take forever, if the DB is fairly large. In both of following ways we don't count rows of each table, instead just look in SQL Server where it is already stored.

Query 1:
SELECT
[TableName] = O.name,
[RowCount] = MAX(I.rows)
FROM
sysobjects O,
sysindexes I
WHERE
O.xtype = 'U' AND I.id = OBJECT_ID(O.name)
GROUP BY O.name
ORDER BY [TableName] ASC


Query 2:
SELECT
'['+SCHEMA_NAME(T.[schema_id])+'].['+T.name+']' AS [Table_Name]
,I.rows AS Row_Count
FROM sys.tables T
INNER JOIN sysindexes I ON (T.object_id = I.id AND I.indid < 2
ORDER BY [Table_Name]


It should be noted that both of above queries give an approximate count only, because of sysindexes table is usually a little bit inaccurate, due to it is not updated constantly.

Monday, September 13, 2010

Running Dynamics CRM 4.0 with a Service Account

When I install CRM 4.0, I got the warning message "Verify Domain User account SPN for the Microsoft Dynamics CRM ASP.NET Application Pool account" in system requirements window. But it did not prevent me from installing CRM, so I proceeded.



After successfully completing other steps I couldn't browse CRM page. I was getting an error message saying "Caller does not have enough privilege to set the CallerOriginToken to the specified value.” To resolve this problem I had to follow following steps.

1. Using Setspn command line tool, setup the SPNs for the machine and service account as follows
.
setspn –a HOST/servername.domainabc:5555 domainabc\serviceusername


The Setspn command line tool is included in Windows Server 2003 Support Tools and you can download it from the Microsoft Download Center in this location.
You can find "Setspn Overview" from Microsoft TechNet in this location.

2. Verify/ Add the Microsoft Dynamics CRM server to the CRM installation’s Active Directory PrivUserGroup group by following these steps.

2.1 Locate the correct security group if you have more than one deployment of Microsoft Dynamics CRM 4.0 in the domain. Run the following SELECT statement on MSCRM_Config database using SQL Server Management Studio.

SELECT ID, DatabaseName, FriendlyName FROM Organization

2.2 Add the Microsoft Dynamics CRM server to the Active Directory PrivUserGroup group.
...1. Start -> Run -> dsa.msc, then click OK.

...2. Locate the organizational unit in which the Microsoft Dynamics CRM installed.

...3. Double click PrivUserGroup, click Members, and then click Add.

...4. Click Object Types, click Computers, and then click OK.

...5. Use Check Names option to find out Microsoft Dynamics CRM server, and then click OK.

3. Add the service account to the local machines IIS_WPG group.

4. Restart Microsoft Dynamics CRM server.
5. Restart Microsoft Dynamics CRM client for Outlook.

Tuesday, March 10, 2009

NTFS File System for USB Flash Drives

Recently I came across a situation where I wanted to copy a virtual hard disk (which is about 12GB in size) to my USB drive. Though there was enough free space on the disk I wasn't able to copy the file. Reason for this was maximum file size allowed in FAT file system is 4096MB.

So I thought of formatting my flash drive with NTFS file system and just searched for pros and cons.

Pros:

  • Avoid file size restriction
  • NTFS allow file compression
  • Manage permissions for individual files and folders
  • Use windows XP built in file encryption

Cons:

  • Additional data writes – NTFS logs disk transactions separately on the disk adding considerable amount of extra disk activity, which leads to wearing out your USB drive faster
  • Windows 98/ ME, and most Linux systems cannot read NTFS partitions
  • Must go through removal dialog, or else you have a good chance of losing data as you have to switch from the 'Optimize for quick removal' mode

Therefore it is up to you to choose between formatting flash drive with NTFS or not. As I read, if you have done your research and decided to format your flash drive with NTFS, here is how to do it.

  • Right Click My Computer-> Select Manage-> Open Device Manager
  • Select your USB Drive-> Right Click-> Select Properties-> Select Policies Tab -> Select Optimize for performance option-> Click OK

  • Open My Computer-> Right Click on your USB Drive-> Select Format-> Select File System as NTFS-> Start

A good article on "Format a USB drive with NTFS file system" can be found here.

Friday, February 6, 2009

Install & Configure Microsoft Commerce Server 2007

1. Install Microsoft Commerce Server 2007 Developer Edition on a standard Visual Studio 2005 workstation with default options selected. If you don't want to develop web applications Microsoft .NET Framework 2.0 is sufficient.

Commerce Server 2007 needs several prerequisites, including .NET Framework 2.0 and IIS. If these main prerequisites are installed, you can select "Automatically install the platform prerequisites" option so that additional components like hot fixes will be downloaded and installed during the installation process.

Before you install Commerce Server, you must create several accounts to run the Commerce Server services. Refer "Create User Accounts" section in the installation guide for more information.

2. Commerce Server Configuration Wizard allows you to configure commerce server and it can be found in start menu. Once you configured commerce server, it won't allow you to configure again. In the case invoke "CSConfig.exe /f" from Commerce Server command prompt to force the new configuration.

In the configuration wizard select a DB Server to create admin DBs (EX: MSCS_Admin)

3. Unpack .pup file (site) using Commerce Server Site Packager.

This will create Commerce DBs, Web services and application virtual directory.

4. Make sure you granted all relevant permissions, so that application can connect to the DBs (Create Users/Roles in DB, Setup AppPools in IIS).

5. Assign users to commerce server web services in AzMan.

Open AzMan.msc, open AzMan store from xml files that is in each unpacked Web Service folder (Right Click the Authorization Manager node and click on Open Authorization Store). (EX: CatalogAuthorizationStore.xml)

Add your domain account to the roles you wish to manage in Azman (Ex: Go to CatalogAuthorizationStore -> CatalogandInventorySystem -> Role Assignments -> Administrator. Then right click on the roles you wish to manage and choose "Assign Windows Users or Groups").

6. Install Business User Applications on a work station.

Before installing follow these sections in the "installation Guide" to grant required permissions.

  • Assign Write Permissions to the Catalog Authorization Policy
  • Assign Write Permissions to the Temporary ASP.NET Folder
  • Assign Permissions for the Windows Temporary Folder
  • Add Users or Windows Groups to the Authorization Policy Roles
  • Add Users or Windows Groups to the Authorization Policy Roles
  • Add the Worker Process Accounts to the IIS_WPG group

7. Then Configure Catalog Manager, etc to your Web Services and you are done!!!

In case if you get "WebService was not available" error message and WebServices can be navigated through IE without any issue, the reason would be the Catalog Web Service does not have write access to the AuthorizationPolicy path.

To resolve this issue you have to assign write permissions on CatalogAuthorizationStore.xml to the account running the AppPool. (CatalogAuthorizationStore.xml file can be found in the same directory as CatalogWebService.asmx. Account running the AppPool can be found from IIS Manager.)

Hope this help someone, as configuring Commerce Server is always tricky.

Tuesday, December 30, 2008

Unlock TFS Files Locked by Other Developers

It is a common experience that someone needs to unlock a file, locked in Team Foundation Server by another developer at a moment that the developer who locked the file is not available to unlock it. Same thing happens if the original login used for lock a file is no longer exists. For the both cases one solution would be the use of 'tf undo' command from Visual Studio command prompt. The undo command removes any locks so that other developers can check out the file. It should be noted that you should have enough privileges to execute this command. Command syntax is:

tf undo /Projects/Project1/Controls/FileName.cs"
/WORKSPACE:Dev123;Domain\UserName /s:http://tfs01:8080 /recursive

Here the Workspace and the User are the ones who locked the file. This information can obtain from source control explorer. If you want to find list of files locked by a developer use the 'tf status' command.

One important thing to remember when using 'tf undo' command is, you may have to use server name as "http://…" if you are executing command from a developer box. Otherwise you will get the ‘cannot find server’ error message for server name as well as for IP address though you are in the same domain, etc. By using server name as a URL it will uses web services to invoke the command.

You can read more detail about “Tf Command Line Utility Commands” from MSDN here.

Sunday, May 4, 2008

How to install Active Directory in Windows Server 2003

This is a simple guide to install Active Directory with a Domain Controller and a new Domain in a Windows Server 2003 machine as a fresh installation. Before begin the installation make sure you have the Windows Server 2003 installation CD.

1. Go to Start -> Run

2. Type the command “dcpromo”, hit “Enter”

You will get “Active Directory Installation Wizard”

3. To continue, click “Next”

4. Click “Next” again after reading OS Compatibility

5. Here you will be given two options to create a “Domain Controller for a new domain” or to create “Additional domain controller for an existing domain”.

Assume here we are going to create a “Domain Controller for a new domain”. Select 1st option and click “Next”


Domain controllers

When you create the first domain controller in your organization, you are also creating the first domain, the first forest, the first site, and installing Active Directory. Domain controllers running Windows Server 2003 store directory data and manage user and domain interactions, including user logon processes, authentication, and directory searches.

Determining the number of domain controllers you need

A small organization using a single local area network (LAN) might need only one domain with two domain controllers for high availability and fault tolerance. A larger organization with many network locations will need one or more domain controllers in each site.


6. Now you will get the “Create New Domain” window with 3 options to create a new “Domain in a new forest” or “Child domain in an existing domain tree” or “Domain tree in an existing forest”

Assume we are going to create a new “Domain in a new forest”. Select 1st option and click “Next”


Domains

Domains are units of replication. All of the domain controllers in a particular domain can receive changes and replicate those changes to all other domain controllers in the domain. Each domain in Active Directory is identified by a Domain Name System (DNS) domain name and requires one or more domain controllers. If your network requires more than one domain, you can easily create multiple domains. One or more domains that share a common schema and global catalog are referred to as a forest. The first domain in a forest is referred to as the forest root domain.


7. You will be taking into “Install or Configure DNS” window with 2 options to “Configure the DNS client”, if DNS is already running on the network or to “Install and configure DNS on this computer”.

I’ll select second option here. So I have to Install and configure a DNS. Click “Next” to continue.

8. Give “Full DNS name for new domain” (Ex: “name.company.com”) and click “Next”

9. Give “NetBIOS Domain Name” (This is the name that users of earlier versions of Windows will use to identify the new domain) and click “Next.

10. Select locations to store “Database and Log Folders” (It is recommended to store these files in a separate hard disk). Click “Next”.

11. Select a location as a “Shared System Volume”. This is the place where server store domain’s public files. This location must contain NTFS file system.

12. You will be given two options to select “Permissions” with backward compatibility of operating systems up to Windows 2000 or including pre-Windows 2000 server operating systems. I select up to Windows 2000. Click “Next”

13. Provide a password for restore mode and confirm it.

14. Here you can see the summary of what have done so far. Click “Next” to continue.

15. Wait several minutes till system configure the Active Directory. You may ask to insert Windows Server installation CD while configuring. (Note: If your system has dynamically assigned IP address, configuration process will complain. So you must have to get a static IP for your machine)

16. You’re done. Congratulations.

Tuesday, February 19, 2008

How to Install ColdFusion 8 on Linux?

Grant Execute permission to the Coldfusion‐8‐lin.bin binary file

chmod +x Coldfusion‐8‐lin.bin

Execute Coldfusion‐8‐lin.bin
./Coldfusion‐8‐lin.bin

Enter the Locale
1 (English)

Hit Enter 28 times to continue the agreement

Enter “Y” to accept the agreement

Enter the version to install
3 (Developer Edition)

Enter the next task to perform
1 (Server Configuration)

Enter whether you have an existing server configuration
2 (No existing server configuration)

Enter the next task to perform
5 (continue installation)

Enter the installation path
Hit enter to accept the default path

Hit Enter 30 times to continue the agreement

Enter “Y” to accept the agreement

Enter the serial number

Hit Enter for no serial number

Enter whether you have an existing CF installation
2 (no existing CF installation)

Enter the next task to perform
1 (Add Web Server Configuration)

Enter the web server to configure
1 (Apache)

Enter the path to the directory containing the Apache config file (httpd.conf)
/etc/httpd/conf

Enter the path to the Apache binary files
/usr/sbin/httpd

Enter the path to the Apache control file
/etc/init.d/httpd

Enter the next task to perform
4 (continue with the installation)

Enter the path to the web root

Hit enter to select the default location

Create a new Linux user

Enter the username / password

Confirm password

Enter whether you need to enable RDS
Y (Enable RDS)

Enter the password for RDS and confirm

Hit enter to exit the installer

When installation completes the installer will prompt you to start the ColdFusion server

Change directory to the ColdFusion binary directory
cd /opt/coldfusion8/bin

Start coldfusion8
./coldfusion start

There are three possible messages you will get
- Installation successful
- Installation failed
- Installation failed and retry for 12 times

If you are done with the installation successfully please ignore following instructions

Installer normally don’t update file paths correctly please edit following two files for the given file paths,

Files:
/opt/coldfusion8/bin/cf‐connectors.sh
/opt/coldfusion8/bin/connectors/apache_connector.sh

Paths:
Apache config file (httpd.conf): /etc/httpd/conf
Apache binary files: /usr/sbin/httpd
Apache control file: /etc/init.d/httpd

Check whether you have following file on the file system,
/opt/coldfusion8/runtime/lib/wsconfig/1/mod_jrun20.so

If Yes, go to label “Final

If No, Continue with following instructions,

Grant permission to following three files (permissions should be same as the httpd file)

Files:
/opt/coldfusion8/bin/cf‐connectors.sh
/opt/coldfusion8/bin/connectors/apache_connector.sh
/opt/coldfusion8/runtime/lib/wsconfig.jar

Command:
chcon ‐‐reference=/usr/sbin/httpd \/opt/coldfusion8/bin/cf‐connectors.sh
chcon ‐‐reference=/usr/sbin/httpd \/opt/coldfusion8/bin/connectors/apache_connector.sh
chcon ‐‐reference=/usr/sbin/httpd \/opt/coldfusion8/runtime/lib/wsconfig.jar

Start ColdFusion Server

Change directory to the ColdFusion binary directory
cd /opt/coldfusion8/bin

Restart coldfusion8
./coldfusion stop
./coldfusion start

Check whether you have following file on the file system,
/opt/coldfusion8/runtime/lib/wsconfig/1/mod_jrun20.so

Yes it should be in the file system. Continue with the following instructions,


Final:

Grant permission to following file (permissions should be same as the httpd file)

File:
/opt/coldfusion8/runtime/lib/wsconfig/1/mod_jrun20.so

Command:
chcon ‐‐reference=/usr/sbin/httpd \/opt/coldfusion8/runtime/lib/wsconfig/1/mod_jrun20.so

Restart coldfusion8
./coldfusion stop
./coldfusion start

Start the apache server

You are done with the installation

Access the site http://localhost/CFIDE/administrator/login.cfm

Continue the wizard and you are ready to use the ColdFusion server.
Congratulations!

Thanks, Darshatha and Gayan for preparing this document. Hope it will help you all.