Sunday, November 25, 2012

Why and How Businesses should use Social Network

Here are some guidelines of why and how business should use social network to build huge customer/user base.

1) Facebook - 800 million+ users

News feed is where people – one billion of them – spend their time on Facebook – in fact, 40% of their time. News feed is real-time personalized news paper written by the friends and business people care about. It’s always up-to-date; it’s in their pocket everywhere they go and its most engaging place.
  1.  Create Facebook page.
  2. Create ads and target based on location, demographics and interests.
  3. Engage users by posting updates, photos and questions.
  4. Influence friends of friends by sponsored stories, share, comments and recommendations.
  5. Create app/game on Facebook to attract people. People trust their friends so it’s great way to market.
  6. Invite people to like page through mass mailing. 
  7. Facebook Like and Share plugin - drive most users to the site

2) LinkedIn – 175 million members

Reach Professionals on LinkedIn. Connect with the world's largest audience of active, influential professionals.
  1. Create LinkedIn Business page/Group
  2. Keep it up-to-date
  3. Invite users – mass mailing
  4. Run linked ads
  5. LinkedIn share plugin - drive most users to the site

3) Twitter

Twitter is an information network that brings people closer to what’s important to them. 340 million tweets per day by 140 million+ active users. Over a billion Tweets sent every three days. These Tweets represent conversations related to almost any topic imaginable. 
These conversations provide a rich canvas and a powerful context in which to connect our messages and brand to what people are talking about right now. It’s a canvas for telling engaging stories, for participating in cultural events, for broadcasting content, for connecting directly with consumers, and for driving transactions.

  1. Create twitter account
  2. Keep it up-to-date
  3. Promoted tweet – extend the reach to broader audience.
  4. Promoted accounts – turbocharge follow rate to build strong base of followers

Hope you find it useful.


Sunday, September 18, 2011

Solved: Exceeded Column Length error when configuring claims authentication when selecting a certificate

While configuring Internet facing deployment Deployment manager throws error and closes. Error is caused when length of SSL certificate name exceeds 128 characters. After searching a lot I ended up with a simple solution.

Please note this is an unsupported way, so please backup MSCRM_CONFIG database before making any changes listed below so that you can restore in case anything goes wrong.

Issue is caused because table Certificates column Name size is 126. We need to increase that from back end to make it work.

Simple Solution:

Execute following script on MSCRM_CONFIG database

  1. ALTER TABLE Certificates ALTER COLUMN Name NVARCHAR(256);
  2. SELECT cast(ConfigurationMetadataXml as xml)
    FROM [MSCRM_CONFIG].[dbo].[ConfigurationMetadata]

  3. Open XML in editor
  4. Search for tag <Table Name="Certificates"> and go to <Column Name="Name">
  5. Modify length to 256 instead of 128 <Length>256</Length>
  6. Make sure to replace all (') quotes with ('') twice quotes to allow update else SQL will throw errors

  7. UPDATE MSCRM_CONFIG.dbo.ConfigurationMetadata
    SET ConfigurationMetadataXml = 'place modified xml contents here'


When running the Claims Authentication Wizard in the Dynamics CRM Deployment Manager to configuring Claims Based Authentication and you select a certificate that has a name longer than 128 characters Deployment Manager crashes.
The error in the Platform trace is:
Crm Exception: Message: Exceeded column length: Column Name, ErrorCode: -2147220970
[2010-11-04 20:17:36.256] Process: mmc |Organization:00000000-0000-0000-0000-000000000000 |Thread: 3(SnapIn/Main-thread.) |Category: Platform.Sql |User: 00000000-0000-0000-0000-000000000000 |Level: Error | CrmCertificateService.Create
Exception creating Certificate, Name=(CN long_certificate_name :Exceeded column length: Column Name)


There is a limit of 128 characters that a certificate name can have if it is the certificate being selected during the Claims Authentication Wizard.

Solution from Microsoft:

Select a certificate that has a name less than 128 characters.

Wednesday, November 3, 2010

SQL Server - Search SQL object used in all database

Some times we pass through situation where we need to search specific object ever used in all databases.

Example: Finding whether Employee table in Payroll database is used in Accounts database. If yes than which are views, procedures table has been  used.

Below is simple query which will browse through each database to search given Table

open dbcur



--find in views

DECLARE @sql nvarchar(500)
DECLARE @ParmDefinition nvarchar(500)
DECLARE @cnt int

SET @sql = N'SELECT @cntout = count(*) FROM [' + @dbname + '].INFORMATION_SCHEMA.VIEWS WHERE view_definition like ''%Employee%'''
SET @ParmDefinition = N'@cntout int OUTPUT';

EXECUTE sp_executesql @sql,@ParmDefinition,@cntout=@cnt output

if @cnt > 0 
print convert(nvarchar(10),@cnt) + ' views in ' + @dbname

--find procedure

SET @sql = N'SELECT @cntout = count(*) FROM [' + @dbname + '].sys.sql_modules modu
INNER JOIN [' + @dbname + '].sys.objects obj ON modu.object_id = obj.object_id
WHERE obj.type = ''P'' AND modu.definition like ''%%Employee%'''

SET @ParmDefinition = N'@cntout int OUTPUT';
EXECUTE sp_executesql @sql,@ParmDefinition,@cntout=@cnt output

if @cnt > 0 
print convert(nvarchar(10),@cnt) + ' procedures in ' + @dbname


close dbcur
deallocate dbcur

Hope it helps.

Monday, September 6, 2010

Redmine - Bulk Import for LDAP users

If you configure LDAP for authentication, users are not visible unless they have at least logged in once. This is not ideal in terms of usability. You have to tell your users to login but they can't do anything because there are not member of any project (yet) and you can't add them because they don't exist (chicken and egg).

To solve this we created a PHP script to implement Bulk Import in Redmine database.

/* ----------------- PHP script ------------------- */

//Postgres Variables

$pg_sqldb_host = "pghost";
$pg_sqldb_user = "pguser";
$pg_sqldb_pass = "pgpass";
$pg_sqldb_name = "redmine";

// LDAP variables
$ldaphost = "";  // your ldap servers
$ldapport = 389;  // your ldap server's port number

// Connecting to LDAP
$ldapconn = ldap_connect($ldaphost, $ldapport) or die("Could not connect to $ldaphost");

ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);

$login = ldap_bind( $ldapconn, "ldapuser", "ldappass" );

$attributes = array("uid", "displayname", "mail");
$filter = "(uid=*)";

$result = ldap_search($ldapconn, $search_base, $filter, $attributes) or die("error in query") ;

$data = ldap_get_entries($ldapconn, $result);

$redmine_link = pg_connect("host=$pg_sqldb_host port=5432 dbname=$pg_sqldb_name user=$pg_sqldb_user password=$pg_sqldb_pass") or die("Could not connect to Redmine: " . pg_last_error());

$query = "select MAX(id)+1 from users";
$result = pg_query($redmine_link, $query);
$nextid = pg_fetch_result($result, 0, 0);

for ($i=0; $i<=$data["count"];$i++) {

$query = "select id from users where login='" . $data[$i]["uid"][0] . "'";
$result = pg_query($redmine_link, $query);

$rows = pg_num_rows($result);

if($rows == 0 )
$name = split(" " , $data[$i]["displayname"][0]);

$query = "INSERT INTO users (id, login, firstname, lastname, mail,        mail_notification, admin, status, language, auth_source_id, created_on, type)
VALUES($nextid,'" . $data[$i]["uid"][0] . "','" . $name[0] . "','" . $name[1] . "','" . $data[$i]["mail"][0] . "',false,false,1,'en',$auth_source_id,CURRENT_TIMESTAMP,'User')";

$result = pg_query($redmine_link, $query);
$rows = pg_affected_rows($result);

//user doesn't exists add user
echo ("User " . $data[$i]["uid"][0] . " added successfully

echo ("User " . $data[$i]["uid"][0] . " already exists



print("Users imported successfully


/* ----------------- end of script ------------------- */

You may add script in schedule to run every 24 hours.

Linux : add php script in crontab. 
0 0 * * * *  root /user/bin/php /path/phpscript >> /var/log/logfile

Windows: add php script in windows scheduler.

Comments are most welcome.

Thursday, August 12, 2010

Official website of Shrinathji Temple, Nathdwara

Shrinathji Temple, Nathdwara

Shrinathji Temple, Nathdwara has launched official website. Website provides latest information about Shrinathji Temple, along with online services like Donation, Darshan Timings, News, Events, Cottage Booking for New Cottage and Dhirajdham.

Wednesday, August 11, 2010

Subversion + Redmine + LDAP automatically generate AuthzSVNAccessFile

Subversion + Redmine + LDAP automatically generate AuthzSVNAccessFile

While implementing Redmine we came across difficulty integrating Redmine and Subversion using LDAP. One of the main reason was subversion uses AuthzSVNAccess file to authorize users. We don’t want all LDAP users to access SVN, only users added in respective Redmine project should able to access SVN repositories.
To solve this we end up creating PHP scripts to auto generate AuthzSVNAccessFile based on Redmine database. Script can be added to crontab to run periodically. Below are detail steps and script.
1) Install Redmine
2) Install Subversion
3) Automatically create SVN repository when a new project is added in Redmine

Add this script in crontab on Subvserion server (in case your subversion is hosted on different server). Below script is scheduled to run every 10 minutes.
10 * * * * root ruby /root/redmine-1.0.0/extra/svn/reposman.rb --redmine-host http://my.redmine./ --svn-dir /data/svn/ --url my.svn.server --key=mykey --owner apache --verbose >> /var/log/reposman.log

4) Configure Apache to use LDAP for subversion

ErrorDocument 404 default

DAV svn

Require valid-user

SVNParentPath /data/svn/

SVNListParentPath off

#LDAP configuration

AuthType Basic

AuthName "USVN"

AuthBasicProvider "ldap"

AuthLDAPURL "ldap://ldapserver"

authzldapauthoritative on


AuthLDAPBindPassword "LDAP Password"

Require valid-user

# Path to AuthzSVNAccessFile which will be auto generated using script

AuthzSVNAccessFile /etc/svn-acl-conf

5) PHP script to automatically generate AuthzSVNAccessFile

$authfile = "/etc/svn-acl-conf"; //path of AuthzSVNAccessFile

//redmine database detail. I have used Postgres.

$pg_sqldb_host = "localhost";

$pg_sqldb_user = "redmine";

$pg_sqldb_pass = "redmine";

$pg_sqldb_name = "redmine";

$fp = fopen($authfile, "w");

fwrite($fp, "# Subversion authorization file created by script \n");

$redmine_link = pg_connect("host=$pg_sqldb_host port=5432 dbname=$pg_sqldb_name user=$pg_sqldb_user password=$pg_sqldb_pass") or die("Could not connect to Redmine: " . pg_last_error());

#section [groups]

fwrite($fp, "[groups]\n");

#create groups from redmine projects

$query = "select id,name,identifier from projects";

$result = pg_query($redmine_link, $query);

while ($row = pg_fetch_array($result,NULL,PGSQL_ASSOC)) {

$group_name = $row["identifier"];

$group_id = $row["id"];

$group_users = NULL;

//get users for this group

$query = "select, b.login from members a, users b where AND a.project_id=$group_id";

$usvn_users_result = pg_query($redmine_link, $query);

while ($userrow = pg_fetch_array($usvn_users_result,NULL,PGSQL_ASSOC)) {

$group_users = $group_users . ($group_users != NULL ? ", " : "") . $userrow["login"];



fwrite($fp, "$group_name = $group_users \n");



#section [project]

fwrite($fp, "\n\n#Projects from Redmine \n");

$query = "select id,name,identifier from projects";

$result = pg_query($redmine_link, $query);

while ($row = pg_fetch_array($result,NULL,PGSQL_ASSOC)) {

$project_name = $row["name"];

$project_id = $row["id"];

$project_identifier = $row["identifier"];

fwrite($fp, "#Project $project_name \n");

fwrite($fp, "[$project_identifier:/] \n");

fwrite($fp, "@$project_identifier = rw \n\n");





print("SVN Auth file $authfile generated sucessfully");


//End of code
- Make sure apache user has write access to AuthzSVNAccessFile- Add PHP script in crontab to run every 10 minutes10 * * * * /usr/bin/php /path/myscript.php

Tuesday, July 21, 2009

Clicking AutoCompleteExtender scrollbar causes postback

Clicking the AutoCompleteExtender scrollbar causes postback when attached to a TextBox where AutoPostBack="true", below is a workaround to resolve issue.

Workaround is just to check whether focus is on extender popup. If focus is on extender do not sumit (postback) form.

See example below

<script language=javascript>
function checkFocusOnExtender()
//check if focus is on productcode extender
if ( $find('aceProductCode')._flyoutHasFocus )
return false;

<form id="form1" runat="server" onsubmit="return checkFocusOnExtender();">

<asp:TextBox ID="txtProductCode" runat="server" CssClass="textbox" AutoCompleteType="disabled"
AutoPostBack="true" OnTextChanged="txtProductCode_TextChanged"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="aceProductCode" runat="server" TargetControlID="txtProductCode"
UseContextKey="true" ServiceMethod="GetProductCode" CompletionInterval="10" EnableCaching="true"
CompletionSetCount="100" MinimumPrefixLength="1" DelimiterCharacters=";, :" CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"">