Thursday, July 28, 2011

Open a utf8 encoded file saved in windows on unix or linux

Programmatic creation of xml files using c# in a sharepoint library. These files are then manually sent over to a linux system that reads these files using bash od command. The output of the linux command sees 3 special characters in front of the xml declaration tag which is not visible when we open the file in notepad on windows.

The 3 special characters are displayed due to BOM (Byte order marker) present as the first character in the generated xml file which is not visible in notepad. The solution is to remove the BOM character programmatically before writing the file to disk / sharepoint.

This can be easily achieved using,

Pass false as a parameter to the constructor so that it ignores the BOM while encoding files.

Wednesday, July 27, 2011

SP2010 Tag external sites.

Click on Tag this page on an internal site and read the information on the dialog box.

Tuesday, July 26, 2011

SharePoint Most Popular / Viewed Documents webpart

Ideas to build a SharePoint Most Popular Documents webpart

1. IIS Log
a. we use a logparser to push iis logs to db monthly for reporting. tweak the code to push only document read info to a db table daily.
b. build a webpart to read the sql table.
2. Audit logs (bad idea)
a. turn on site collection audit logs to track document view.
b. use audit log object model to read the info you need.
3. Site collection usage reports -> i dont know if the reports store the document information. I dont think it does, maybe worth a check.
4. Complicated approach, but could be extended,
a. Deploy a delegate control at site(any level?) level with some javascript, which will track document clicks (trust me this will be complicated) and uses ajax to store it back the server in a config list.(It could just write to a links list).
b. Use the list view webpart / custom webpart to display the list view.

Saturday, July 16, 2011

Read sharepoint xml file into memory dataset

using (MemoryStream mStr = new MemoryStream(folder.Files[0].OpenBinary()))

Friday, July 15, 2011

Create SPFolder and upload SPFile programmatically

SPList list = web.GetListFromUrl(u);
SPFolder folder = web.GetFolder(string.Format("0}/{1}",list.RootFolder.Url,foldername));
if (!folder.Exists)
folder = list.RootFolder.SubFolders.Add(foldername);

using (MemoryStream stream = new MemoryStream())
SPFile file = folder.Files.Add(filename, stream);

Thursday, July 14, 2011

Add user to email distribution list

Email distribution lists can be easily manipulated using ADSI code (System.DirectoryServices) and LDAP protocol.

ampersand .net app.config configuration files

Using & (ampersand) in .net configuration files

You cannot use the & symbol in the application configuration files (web.config and app.config). For your application to work replace the & symbol with "& amp; (without the space in between ampersand and the word amp)"

Add service reference in visual studio for password protected services

Visual Studio does not directly allow to add web reference to password protected secure webservice and it will throw error like you have mentioned. But you can still add web reference to secure webservice by using 2 techniques.

Browse the webservice wsdl in a browser. It will prompt for security login and provide the username/password. Then save the WSDL xml into a file in your local computer.
Then add web reference to this local version of wsdl. In this way, you will be able to add web reference to secure password protected webservice using visual studio. user-agent parse

private float getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
float rv = -1;
System.Web.HttpBrowserCapabilities browser = Request.Browser;
if (browser.Browser == "IE")
rv = (float)(browser.MajorVersion + browser.MinorVersion);
return rv;

private void Page_Load(object sender, System.EventArgs e)
string msg;
double ver = getInternetExplorerVersion();
if (ver > 0.0)
if (ver >= 7.0)
msg = "You're using a recent version of Internet Explorer.";
msg = "You should upgrade your copy of Internet Explorer.";
msg = "You're not using Internet Explorer.";

Label1.Text = msg;


Monday, July 11, 2011

Ubuntu FB upload photo desktop

Upload bulk photos to Facebook using desktop application - Ubuntu

Ubuntu install new packages

Ubuntu install new packages

Project Server 2003 to 2010 Migration.

Technet Center for Project Server:

Migration Center:

Migrate from Project Server 2003

Video and Webcasts:

· Project Server 2003 to Project Server 2007 Migration Best Practices

· Project Server 2010 - Upgrade and Migration (Level 300)

· Project Server 2010 - Backwards Compatibility Mode (Level 300)

Migration best practices:

Thursday, July 7, 2011

Silverlight for Linux

Install moon-light :-))

SharePoint 2007 RSS Viewer unexpected error 407 proxy authentication error

SharePoint is hosted in a DMZ which does not have access to internet. User adds a new RSS viewer webpart on a sharepoint team site and gets the famous error "Unexpected error has occured."

The easiest resolution is to contact the corporate security team to open ports so that the web part can get the requested rss feed. But some rss feeds are hosted on environments which keep changing their IP addresses. This will cause the webpart to stop working after some time and we cannot keep requesting security to open ports based on new IP addresses.

ULS logs indicates either one of the following errors,
a. Connection timed out
b. Connection was closed forcibly.
c. 407 proxy authentication failed.
I could not use the following solution because it is not allowed as per security policies,

Here are two options out of which I implemented option 1,

1. The external DMZ machines could talk to a special server on http port which could then talk to another environment from where we could access the rss feed from the internet. Use System.Net.WebClient and WebProxy classes.

2. Client side programming logic. This would work if the rss feed is accessible from the client and not from the server.
a. On each page loads, use javascript to check server cache if feeds already exist.
b. If cache does not exist, use javascript to get rss feeds using a proxy server.
c. Cache rss feed result on server.
Prefrebly use JQuery or Javascript xmlhttprequest.

Firefox kerberos 401.2 error

We have an intranet sharepoint site using kerberos authentication. The site works perfectly in IE but displays 401.2 authentication error when opened using Firefox.

- Open Firefox
- Type about:config in address bar
- Filter by keys which begin with "negotiate"
- Set the below key values,
-- network.negotiate-auth.delegation-uris = "comma seperate list of domains e.g. ',' "
-- network.negotiate-auth.trusted-uris

Monday, July 4, 2011

Ubuntu Linux install .deb package

1. Download .deb file (e.g. google chrome 32 bit installer)
2. Navigate to folder where .deb file is downloaded on terminal.
3. Run command, $ sudo dpkg -i package.deb

Friday, July 1, 2011

Open/Connect Windows from Ubuntu 11.04

Use "Terminal Server Client" software and select RDP protocol.

Sharepoint site not responding while DocAve 5 security report runs

We have the administration module DocAve v5 and it has an interesting issue which should be resolved in one of its future releases.

Issue: Reports that scan site collections for item level security causes site collections to not respond in browser while the report is running ! The browser keeps spinning without an actual response. Note that this issue occurs only when item level security report is desired.

Avepoint support has fixed this problem and it should be available or maybe already available.