8 Des 2010

Write Windows Event Log using Command Line

Last week I’ve created this small application using VS 2010, targeted to Microsoft.NET Framework 3.5. It’s a small application with simple code, but it’s very useful to Log your message to Windows Event Log in a DOS Batch file environment.

Click to download EventLogger.exe

It’s very simple to use. See the example below.

To create an event log entry with “Error” flag.

To create an event log entry with “Warning” flag.

To create an event log entry with “Information” flag.

SharePoint Open in Windows Explorer Too Slow?

When you try to open SharePoint Library with Open in Windows Explorer feature, sometimes we feel that the process are too slow. This thing is really really frustrating and annoying if you work with bigger files, maybe more than 100 MBs. I’ve found in the internet, couldn’t remember the links, but this is the tips, just turn off the “Automatically detect settings” in LAN Settings in Internet Options. What??? What is that? Here’s the short instructions (for you who don’t know where it is) …

  1. Open your Internet Explorer or Open your Control Panel
  2. Open Internet Options (in Control Panel). From Internet Explorer, you need to browse to the Tools menu before you see Internet Options menu.
  3. Open Connections tab, and click LAN Settings.
  4. Uncheck the Automatically detect settings. Click OK.
  5. You’ve done your job.

29 Okt 2010

Tips to Create a Stronger Password and Manage Admin Users in Your Company

Maybe this topic is to ridiculous to me, but sometimes, for other people, it’s very useful. I’ve traveled so much, meeting so much clients, and see how different company can loose it’s security, or tighten it up. Some company doesn’t realize that their company isn’t protected so much, and could hacked in anytime, and this company is big enough. So, these are the passwords that someone could lost his/her job just for let the default or common password reside in their admin users.

  1. pass@word1
  2. P@ssw0rd
  3. Sequential numbers forward and backward like 123456, or 12345678, or 87654321
  4. princess
  5. Sequential characters like abcdef
  6. Sequential characters in keyboard like qwerty, asdfghj, zxcvbnm
  7. Combination of sequential characters and numbers like abc123, or qwerty12345
  8. If the website name is RockYou.com, the password is sometimes rockyou

So stupid isn’t it? You could prevent all of hacking actions using a stronger password. Stronger password are containing lowercase and uppercase alphabetical and numbers, and special characters. See… I’m using clause “AND”, and you may think that “gILa$2(vk_q0” will meet the requirements, and you may think that password will be lost sometime, because of too hard to remember. And if you try to write it on a paper, someone could stole your paper and see the password.

Try to find some sentences, in a normal ways. If you could, try find it on another language, not in English. Some password cracker application could find the password on it’s library, and think that the password is in English, like “princess”. Try “Admin for Rock You.com”, or “Library Administrator on Department”, or use another language, like in mine, “password goblok”, it means “stupid password”.

And from that point, you could change the sentence into 1 word only and don’t make an obvious password and easy to read, using combination of alphabetical lowercase or uppercase, and numbers, and special characters. Example for “Admin for Rock You.com” is “4Dm1n4RY” or “My@dM1nR0cKY0u”. Or you can try “I don’t remember” changed into “1dnTR3m3m&er” as a password.

In that way, you can still remember the password but with better security.

How to Manage Admin Users?image

Try to disable the domain admin, and create a new user as a domain admin. The Domain Admin in Active Directory is “Administrator”, so if you in Microsoft Corp, maybe the login sentence like “MICROSOFT\administrator”. Before you disabled the Domain Admin, try to create a new standard user, for example “MICROSOFT\pegasus” or “MICROSOFT\superman”, and use the above tips to create password. Join this user to “MICROSOFT\Administrators”, “MICROSOFT\Domain Admins” groups, or any other groups equivalent to “MICROSOFT\Administrator”, and then you can disable the MICROSOFT\administrator”.


If you have any other products like SQL Server or SharePoint, or even ForeFront, or any products which require an administrator user, specify all of admin one by one. Don’t try to use “MICROSOFT\Administrator” or “MICROSOFT\superman” or anything equivalent to Domain Admins. For an example, specify “Microsoft\SQLServerAdmin” for SQL Server, “Microsoft\SPSAdmin” for SharePoint, etc.

Happy configuring…

Optimizing and Improving SharePoint Performance from SQL Server

So, there is some ways to optimize and improve SharePoint (any edition) from SQL Server. There’s some way to improve this SharePoint things, and from SQL Server is one another way to do that. The important key is, where is your MDFs (MDF is the file extension for SQL Server Data File) and LDFs (LDF is the file extension for SQL Server Log File) located? What happens if I lost my MDFs? Or what happens when I lost my LDFs? What path should I take to make SharePoint much faster?

20 Okt 2010

Advanced Download Flash Video Streaming using Fiddler2

Fiddler2 is web debugging tools that you can use to view Request or Response Header, and you can create your own Response or Request Header. But what if you want to use it for fun, not just debugging web? You can use Fiddler2 to download Flash Video Streaming! I haven’t tested it yet on YouTube but DailyMotion.com works just fine. Just download Fiddler2 from their website, find it on Google or you can go through this link http://www.fiddler2.com/fiddler2/.


How to use it? Follow these steps to download Flash Video Streaming…


Run “Fiddler2”



Click “Filters” tab to set filter, and check the “Use Filters” checkbox.


Give checkmark to this field under “Request Header”, and set the textbox to “.flv” or any Flash Video Extension which you want to download. You can give any other filters to make the session result better, like “Show only Internet Explorer traffic”.


Make sure that “File” > “Capture Traffic” is checked.


Open IE and start browsing to stream the Flash Video. When you finally find your video, open it and stream it through IE.


Back to Fiddler2, you can see 2 session opened.



You can try copy the URL and paste it to Download Manager. You can try to “Query Size” if you using Free Download Manager.


If the size is reasonable for video, you can directly click OK to download the file. Otherwise, see another session captured in Fiddler2, and copy the URL, and you can just Query the size.

Note that you can use Fiddler2 to get the URL and download it via download manager.




Note, that you can download any video from other site with this configuration Filters in Fiddler2:

  1. DailyMotion.com, try to change the text with “.mp4” or “.flv”.
  2. Youtube.com, try to look at the text with “/videoplayback?”. To verify if it’s the video or not, click first in the session opened in Fiddler, and click “Inspectors” tab. On the Response Headers section, see the Content-Type, usually “video/x-flv”.

UPDATE (AGAIN Smile with tongue out):

There’s an incoming problem from Anonymous, he/she needs to download a video from a website, in http://egotastic.com/2011/12/2-random-minutes-with-leilani-dowding-video/. Let’s take a look at the pictures below, image will tells you much….Rolling on the floor laughing




Make sure no filters attached


Refresh again the page, and play the video it again, to capture all HTML Traffic…. Captured, and that’s it, find the /videoplayback? URL, and I found it!


To make sure it’s the video, look at the Inspector tab, look at Response Headers, the content type is video/flv or video/x-flv.


Right click on that response, and Copy the URL


Paste it on your favorite download manager, mine is Free Download Manager, and start downloading…


And if finished, look at your saved videos…. voila!


19 Okt 2010

Impersonate Active Directory Account when Connecting to Database using Windows Authentication

Lately I have a little problem, not a major but I’m not comfortable and must get to used to it. Suppose we want to connect to another SQL Server Database, and we don’t have any options except use the WINDOWS Authentication. But frankly, this SQL Server which we want to connect to is in another domain. Yeah, you could try to use Windows Authentication, but the User name field and Password field are grayed out. For example, my notebook wasn’t joined to another domain (with logged on user is RADIT\raditz), and I need to connect to another SQL Server in a different domain (suppose another domain user to connect to is CONTOSO\admin), use the following command-line:

RUNAS /user:CONTOSO\admin /netonly “<the SQL Management Studio exe path>”

RUNAS /user:CONTOSO\admin /netonly “D:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe”


You’ll be asked for the password, and the application will running with that user accounts.


Don’t worry, just insert the SQL Server Name, and click Connect.

16 Okt 2010

Remove HTML Tags when Obtaining Text from SharePoint Field

This is one of simple trick to use when you start to develop SharePoint Web Parts. When you want to get the text of, let’s say “Page Content” field of Pages Library, or any other formatted text field in HTML, and you want to get it without the formatting, then here we go the trick.

You can use SPHttpUtility.ConvertSimpleHtmlToText, with 2 arguments, the HTML formatted text, and the maximum length. And you can use other SPHttpUtility objects or any objects in Microsoft.SharePoint.Utilities to do another tricks. You don’t need to get any further code to get this and that, just point to Microsoft.SharePoint.Utilities, and you’ll get the tricks.

23 Sep 2010

Upgrade License from MOSS 2007 Standard to Enterprise

Well, for some people, this particular steps are unknown, but it’s really easy to do. When you want to change the license type of Microsoft Office SharePoint Server 2007 from Standard License to Enterprise License, you don’t have to uninstall and then reinstall the license. Just enter the license into the Central Administration.


Open the Central Administration, and enter the admin credential.


Click Operations tab.


In the “Upgrade and Migration” section, click the “Enable Enterprise Feature”.

Choose the Enterprise Edition, and enter the License Number, click OK. Wait the Upgrade process in a few minutes, and then proceed to “Enable Features on existing files”.



And you’re DONE!

17 Sep 2010

System.Windows.Forms.Timer is not Working in Windows Service

I’m really surprised to know that System.Windows.Forms.Timer is not working in Windows Service project type. The reason from Microsoft is just like this,

“Server-based timers use the thread pool internally, and the event handler runs in a thread taken from the pool. For this reason, conflicts might occur while the event handler is accessing shared variables and modifying controls and forms.”

For this reason, you can’t use the System.Windows.Forms.Timer to periodically run your custom code. Replace it to System.Timers.Timer will help you resolve the situation. I’m using Visual Studio 2010, so it’s very simple to change this code. After adding the ProjectInstaller to the project, then you see your Windows Service Class, and open it, so VS will open the designer for you.

Your windows service class 

After open, just add the System.Windows.Forms.Timer from the Toolbox window.


Right after that, open the (+) sign before your Windows Service class file in the Solution Explorer window, and open the “Designer.cs” (depending your project, it can be “Designer.vb”). In my project, the file is “ServerCommand.Designer.cs”, double click that file.


Change the content of “InitializeComponents” method, change the System.Windows.Forms.Timer to System.Timers.Timer. See the surrounding red background.


And, you’re done. You can add the Timer elapsed event. Double click your Windows Service class file. Double click your timer, and the “Elapsed” event should be added to the code.


And this is the example code for Elapsed event,

private void Tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
EvLog.WriteEntry("Ex Message", EventLogEntryType.Information);
System.IO.File.AppendAllText(@"D:\PIS-ServiceCommand " + DateTime.Now.ToString("dd-MMM-yyyy HH-mm-sss", System.Globalization.CultureInfo.CreateSpecificCulture("id-ID")) + ".txt", "sss");
} catch (Exception ex)
EvLog.WriteEntry(ex.Message, EventLogEntryType.Error);

Happy Coding…

7 Sep 2010

.NET SSH Connection using SharpSSH

Last week, I’ve been assigned to a new project. I must be able to parse the text output of a router, get the settings, and then doing something magic in .NET, either save it to Active Directory or something. Then, I found this .NET component, for free. You don’t have to pay for it, called SharpSSH. Well, I don’t care about how the DLL connect to the router and get the command output, but I do care of the result of the command output.

You can download the component in the website. The code are really simple, in this example is written in C#.NET. Oh… I almost forgot, you must add the Reference to Tamir.SharpSSH.DLL, and make sure that you add too the DiffieHellman.dll and Org.Mentalis.Security.dll. Actually we don’t really need those 2 DLLs, but Tamir.SharpSSH.dll does. So you must add the reference, or just include the DLL into the Debug folder in order to make your application runs well.

So here you go the code. First, add the “using” directive into top of your code.

using Tamir.SharpSsh;

And you’re ready to make the magic. First of all, there’s so many SSH class objects defined in the Tamir.SharpSSH.dll, but I choose SshShell. This is the code…

SshShell SSHConn = new SshShell("", "dean");
SSHConn.Password = "deanp@w";

Insert the IP, username, and the password, and Connect. Then you might want to look carefully before writing the code, you must first know the router output behaviour. In my environment, first login to the router, the prompt ended with the character like this “>”, and I must type “enable” and Enter, and then insert the password, and the ending prompt changing to “#”. This is important to make your code not “hanging” because of wrong character assigned to the SshShell object.

SSHConn.ExpectPattern = ">";
SSHConn.RemoveTerminalEmulationCharacters = true;
if (SSHConn.ShellOpened)
SSHConn.WriteLine("term length 0");
SSHConn.WriteLine("show run");
sOut = SSHConn.Expect("#");

That’s what I’m talking about. After you’ve connected to the router, then the important thing is you must write your line of command to the router. To get the return and probably get the output to a string variable, you can assign variable like in my example, sOut. When you don’t want to get the return, just “apply” the command you’ve set for the router, just execute the “Expect” method, with the ending response of the router like “#” character.

After all, you must close the object using “Close” method, and you’re done.

31 Agu 2010

Simple LINQ Example on Sharepoint Items Query

Actually I don’t remember much about CAML that came up with Sharepoint. CAML is a basic XML based query to fetch some item based on criteria, just like query on SQL. But, It’s so hard to remember! I want to run code as fast as I can, and here’s the answer, LINQ. So, can we start and try this?

OK, before we start, we must ensure that we have .NET Framework 3.5, coz that’s the framework to do the LINQ, and import System.Core.dll to your project. and add the imports below.

using System.Collections;
using System.Collections.Generic;
using System.Linq;

LINQ gives you so many solution to get queries easily, and you don’t need to remember CAML or whatever you’ve called. You can get raw IEnumerable<SPListItem> from the LINQ, but if you want to iterate through query result, you must use foreach.

IEnumerable<SPListItem> LiColl = from SPListItem Li in Lhr.Items where Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days <= 0 &&
Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days >= (_DayIndex * -1) select Li;

Another way, you can get items, using IList<SPListItem> and you can iterate with any iterator.

IList<SPListItem> LiColl2 = (from SPListItem Li in Lhr.Items where Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days <= 0 && Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days >= (_DayIndex * -1) select Li).ToList();

And the other way, you can get items, and returning array of SPListItem.

SPListItem[] LiColl3 = (from SPListItem Li in Lhr.Items where Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days <= 0 && Convert.ToDateTime(Li[SPD.ReplaceFieldSpaceName("Tanggal Kelahiran")].ToString()).Subtract(DateTime.Today).Days >= (_DayIndex * -1) select Li).ToArray();

Rename Sharepoint Site URL using STSADM

Sometimes you faced a little problem with Sharepoint, and what if the problem is you do not like the existing Site Collection URL? For example, http://intern.contoso.com/sites/HRArea and you want to change it to http://intern.contoso.com/sites/HR ? Try this STSADM Commands…

The method is involving backup, delete and restore command in STSADM, so be careful to do this, and trying not to make any mistakes. First time, you must confirm the old URL and the new URL. Maybe you would like to try my another solution using STSADM, so you don’t need to write the full path of STSADM, coz it so annoying.

STSADM –o backup –url <the old url> –overwrite –filename <the backup filename>

So, the example would be like this, STSADM –o backup –url http://intern.contoso.com/sites/HRArea –overwrite –filename D:\BackupHR.dat. This will make backup for the old URL, including contents.

STSADM –o deletesite –url <the old url>

Make sure that the first command completed successfully, so you can do this command, to delete the old site URL. The example is STSADM –o deletesite –url http://intern.contoso.com/sites/HRArea.

STSADM –o restore –url <the new url> –filename <the backup filename>

And the next command is to restore the backed up site. So the site will run with the new URL. And you’re done….

28 Jul 2010

Easier STSADM Tips by Adding PATH into the Environment Variables

Sometimes you don’t realize that you’re wasting your every seconds just for typing and finding where’s STSADM located. Everytime you remote on a Sharepoint Server, and needs to call STSADM, you type this before calling STSADM…


What a waste time…. eh..! You can try to add the path of Sharepoint 12 Folder, to Environment Variables. Here’s how….


Click Advanced system settings…


Go to tab Advanced and then Environment Variables…


in the System Variables, find PATH, and add the 12 BIN sharepoint folder, usually at “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\”, and don’t forget to add “;” delimiters (without quotesBig Grin).


Missing Site Actions Menu after Sharepoint Backup or Restore

A couple weeks ago, I ran into a problem, it’s so annoying and stupid. I have a scenario that I must copy an entire Site Collection and restore it on another server. After I tried to backup all of site collection and then restore it on another server, all seems good and nothing’s error found. But when I hitting the front page, and click Site Action, some of menus are missing!

After a few days, I found that both of the source and destination server, are locked by default when you try to backup or restore by using STSADM. and you can check the site whether it’s locked or not by using this command.


and this command does unlock the site…


And, voila……. the Site Actions menu shown up again….!!!

Merging Two Virtual Hard Disks with Virtual Server 2005

You can merge two Virtual Hard Disk (VHD) into one VHD by using Virtual Server 2005. But as far as I know, you can only merge VHD with Differencing VHD type. What is that? Differencing VHD actually two VHD, with one as the parent which holds the most common and shares the same configuration with the children VHD. And the other one is the child, which holds the changes in every events.

By merging this two VHD, you can increase a better performance for your Virtual Machine. You can try to merge this two hard disk by accessing Virtual Server Administration WebSite, and click Inspect under Virtual Disks.


After that, choose the Full Path of the Differencing VHD to Inspect, and click Inspect.


Click on the “Merge virtual hard disks”…


You can choose whether to merge with the parent virtual disks, or just create a new merged VHD, is up to your choice. And then click Merge.


And that’s how to do it…