Thursday, December 16, 2010

BizTalk: combing two xml message into one

I ran into the situation where I need to combine two messages into one while developing a BizTalk App for Active Directory Integration.
I used SQL typedpooling to get updates of user information from datebase which contains userID and its Manager's ID as well as some other basic user information (comes from Epicor E4SE), since the Active Directory Adapter I was testing only support using DSN to update manager field of AD user, I have to run a AD query first to the the manager's distinguishedName from AD thus the need to combine them into the final Active Update schema.

Inside BizTalk, you select two messages as input and one destination schema as output in a map, let's say the final input is as below:

 <filtermatch ObjectPath="LDAP://CN=B\, Miss,OU=Finance,DC=subs,DC=mycompany,DC=com">  
 <property Name="sAMAccountName" Value="ABC01" />  
 <property Name="distinguishedName" Value="CN=B\, Miss,OU=Finance,DC=subs,DC=mycompany,DC=com" />  
 <filtermatch ObjectPath="LDAP://CN=B\, Sir,OU=IT Dept,ODC=subs,DC=mycompany,DC=com">  
 <property Name="sAMAccountName" Value="ABC02" />  
 <property Name="distinguishedName" Value="CN=A\, Sir,OU=IT Dept,DC=subs,DC=mycompany,DC=com" />  

the final custom xsl will be as below:

 <xsl:stylesheet xmlns:xsl="" version="1.0">  
 <xsl:output method="xml"/>  
 <xsl:template match="/">  
 <xsl:apply-templates />   
 <xsl:template match="/">  
 <xsl:variable name="Manager" select="Root/Input1/ManagerID/text()" />  
 <xsl:value-of select="Root/Input2/AD/FilterMatch[Property[@Name='sAMAccountName' and @Value=$Manager]][1]/Property[@Name='distinguishedName']/@Value" />  

Please note that normally the AD query will only returns 1 record, the reason I put more than one here is to experiment a bit and try to think of the way to handle choosing the right node based on the 'Master' xml input.

The key here is to use a xsl:variable to hold the Key field and use it in the xpath for matching up Xml Node.

So far I have managed to integrate Active Directory, our ERP system (Epicor E4SE) and infopath form together to achieve the 'single point of truth' for user records in a pilot. will write more about details sometime later.

Monday, November 15, 2010

Update List Column Programmatically for SharePoint 2007

Two ways of doing this:

First one is via SharePoint object model:

SPList oList = oWeb.Lists["Technical"];
SPField myField = oList.Fields["Sub-tag"];
String schema = " xx ";
myField.SchemaXml = schema;

the Second way is via Lists.asmx web service:

XmlNode listNode = mylistsrv.GetList("Technical");
string version = listNode.Attributes["Version"].Value;
string guid = listNode.Attributes["Name"].Value;

XmlDocument xmlDoc = new XmlDocument();
XmlElement updateFields = xmlDoc.CreateElement("Fields");

string fieldXml = "";

updateFields.InnerXml = fieldXml;
XmlNode result = mylistsrv.UpdateList(guid, null, null, updateFields, null, version);

Thursday, July 8, 2010

Adding a button with javascript to sharepoint page

By putting a content editor web part with the following:

<BUTTON onclick="window.location.href='http://intranet/Legal/contracts/Search_URL.aspx?Project_Number='+document.location.href.substr(42,7)">Load\View Project Contracts</BUTTON>

Thursday, July 1, 2010

some useful reference about Kerberos Authentication

- How to: Enable Kerberos Authentication on a SQL Server Failover Cluster

- ISA Server 2006 does not support using cross-domain or cross-forest trusts to include more than one Active Directory domain in a Kerberos constrained delegation scenario.

Monday, June 21, 2010

Deploying a .NET workflow onto a SharePoint List

1. Copy the DLL your workflow creates from the build directory ( inDebug) to the Global Assembly Cache (GAC)
2. Create a directory in the features directory [C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions12TEMPLATEFEATURES] and drop both the feature.xml and workflow.xml files into the directory.

3. Install the feature on your farm, using the following command line statements
stsadm -o installfeature -name DocumentMoveAndShortcut

4. Activate the feature to a site collection

stsadm -o activatefeature -name DocumentMoveAndShortcut -url http://moss2007win2008

(or by going thru the site collection settings:
Activate the newly installed feature by navigating to the "Site Collection Features" page, under "Site Action" -> "Site Settings". Scroll down until you see "New Task Workflow", and click "Activate":)


Monday, June 14, 2010

Business Data Catalog & Custom List

A new notes:

1. With Microsoft ® Business Data Catalog Definition Editor, there is need to manually change MethodInstance to Type "Finder";
2. Unless Single Signin is implemented, the ADF need to have 'RevertToSelf' as authentication mode rather than 'PassThrough';

3. make sure MOSS user have access to database used here;

Here is a link about using SSIS to importing data into sharepoint custom list:

Thursday, April 15, 2010

"Transaction context in use by another session" and linked server

if you use linked server and loopback server then call SPs using the linked server, this scenario is not supported.

you will need to modify the code to call the SP directly.

Tuesday, March 23, 2010

Get Tomcat installation directory in Java


Excel VBA - "operation is not allowed when the object is closed"

This is normally caused by the stored procedure called, you will need to place 'set nocount on' on top of the SP to eliminate the extra information returned.

Monday, March 1, 2010

Mission Critical: SQL Server 2008 General Maintenance

Mission Critical: SQL Server 2008 General Maintenance

15 February 2010

by Buck Woody



Revision 09/21/2009 A

SQL Server 2OO8

General Maintenance


This document contains steps that will assist you in the day-to-day SQL Server 2008 RTM Enterprise Edition (non-clustered) operations. It defines the basics of standard maintenance and checks for a single Instance of SQL Server 2008, and should be used as a starting point.

Review each item, placing a check in the “Confirmed” column when the task line is complete. Any line not marked “Confirmed” should stop the process until you have completed that line item.

This CTL is not meant to be a replacement for the official documentation from the product manufacturer.  


This Critical Task List is identified by a CTL number in the upper right-hand side of this document. You should use the latest CTL (identified by the date and an alpha-numeric code.


You can add additional information to this checklist based on your organization’s need.


Critical Task List 10.02.001All content is the sole responsibility of the server owner; Microsoft Corporate provides no warranties implied or implicit in this document. This document is not a product of the Microsoft Corporation. 


Official Site Link: (Not available at this revision level)

Whenever you receive a supplement affecting your checklist, write in the appropriate information. Printed replacement checklist pages will be made available to you as quickly as possible. A notation on the bottom inside corner of these pages will indicate that they reflect certain supplements.


Comments and questions should be directed through buck.woody@microsoft.comCritical Task Lists Managers

Buck Woody “Real World DBA”(MSFT U.S.).






Server and Database Settings Configured for Environment.



Latest Service Packs Installed.



Database Mail Configured and Tested.



Maintenance Wizard or other Automated Maintenance Implemented.



Baseline Performance Metrics Created and Archived.



Backups Checked.



Windows Event Logs Reviewed.



SQL Server Error Logs Reviewed.



Drive Space Checked.



Jobs History Reviewed.



Backups Taken.



Indexes Updated.



Statistics Updated.



Indexes Reviewed.



Long-Running Queries Reviewed



Data Archival Performed.



Security Reviewed.



Service Packs and OS Security Bulletins Evaluated and Applied.



Security Tests Performed.



New Performance Baseline Recorded.



Restore Tests Performed on Production Server to Backup Server.



Performance Reviews Completed from Baseline Comparisons.



Growth Predictions Created from Baseline Metrics.



Instance Audit Performed.



Version Upgrade Plan Evaluated.



This email has been scanned by the MessageLabs Email Security System.
For more information please visit

Thursday, February 25, 2010

use web service to transfer multiple files at once in c#

I recently wrote a web service for E4SE, eBackoffice and PeachTree financial application (which is a financial app used by a branch office) integration, since our E4SE/EBO servers are running on our data centre while PeachTree app runs at remote office and I don't yet have the access to the remote site, I have decided to write a web service to transfer the data output. I have to point out though, the core EBO procedures were written by our colleague not by me:-)

Here are the highly summarized steps:

1. use zip lib (dotnetzip etc) to compress multiple files into 1 archive;
2. Create web service method that has a return type of byte array, read the content of the zip archive and return it;
3. on client side, call the web service and catch the returned value into a MemoryStream, flush it into filestream;
4. if neccessary, write code to extract the zip file automatically

Sunday, February 14, 2010

Transparent Proxy with squid


* httpd_accel_host virtual
* httpd_accel_port 80
* httpd_accel_with_proxy on
* httpd_accel_uses_host_header on
* acl our_networks src xx.xx.xx.xx yy.yy.yy.0/24
//xx.xx.xx.xx -> ip for outgoing interface
//yy.yy.yy.0 -> internal IP
* http_access allow our_networks
* http_access allow localhost
* http_access deny all

Script for iptables:

// eth0 -> internal NIC
// eth1 -> outgoing NIC
iptables --flush # Flush all the rules in filter and nat tables
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

policy based route and transparent proxy

Consider the following scenario:
you have a default gateway that connects to corporate WAN as well as providing external access, since internet access is occupying a significant amount of bandwidth, you want to redirect internet traffic to an alternative internet connection, probably local broadband link.

I have been thinking about a way to achieve this for sometime and came up with the idea:

1. use a logon scirpt to define route, direct all corporate traffic to use corporate WAN gateway and external access to use the alternative connection.
2. install linux + squid + iptables on the machine that connect directly to the local broadband, configure it as a transparent proxy to take advantage of caching.

this hasn't been tested yet, hopefully I will be able to build the lab when I get some spare time.


this approach seems to be bit buggy and may not be the best option, I am looking into the following relevant topic: PBR, WPAD, WCCP and hopefully will find out something more robust.

the best way I can think of now is to add an interface to the WAN router which connect to the transparent proxy, configure the router with static route to corporate WAN interface for internal traffic and all other traffic to go thru the transparent proxy.

Thursday, February 11, 2010

A simple iptables config file

-A INPUT -i lo -j ACCEPT
# -A INPUT –p tcp --syn -m limit --limit 5/second -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A INPUT -p icmp -j ACCEPT

Sunday, January 17, 2010

setting up exchange 2007 on a single server without edge server

1. install all exchange 2007 roles except edge server;
2. configure mx record;
3. create send connector;
4. create receive connector (internet) and enable anonymous access;
5. add accepted domain address space;
6. map owa web address to external web;

Sunday, January 10, 2010

KB970876 - Error 1316.A network error occurred while attempting to read from the file SSCERuntime-ENU.msi

You may receive "Error 1316.A network error occurred while attempting to read from the file Path\SSCERuntime-ENU.msi" error message when you repair an instance SQL Server 2008

vmware vcb backup & CLi commands

VCB Backup with/without VC:

vcbmounter -h virtualcenter -u vcbadmin -p MyPassword1 -a name:blackberry -r e:\vcbbackup\blackberry -t fullvm -m san
vcbmounter -h esxi host -u vcbadmin -p MyPassword1 -a name:blackberry -r e:\vcbbackup\blackberry -t fullvm -m ndb

Manage VM:

(Esxi 4)
vim-cmd vmsvc/getallvms
vim-cmd vmsvc/ vmid
vim-cmd vmsvc/power.on vmid
vim-cmd vmsvc/power.reboot vmid

(ESx 3.5)
# vmware-cmd -l
# vmware-cmd /nas/vms/FreeBSD/FreeBSD.vmx start|stop|reset|suspend|getstat

shutdown -h now