Posts

Showing posts from December, 2010

Find Column in Database - SQL Server

Use the following query to find column in your database. Change “yourdbname” and “%ColumnNameToSearch%” column name accordingly.Use yourdbname
GO
SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%ColumnNameToSearch%'
ORDER BY schema_name, table_name;Thanks to Pinaldave.

Enumerating Active Directory object properties using C#

I had to look up for a properties in Active Directory against my login. Since I didn’t even know the name of properties, I had to enumerate through them. Here is the code.1. Create C# application and add a configuration file “app.config”.2. Update it as follows:<configuration>
  <appSettings>
    <add key="ADDomain" value="mydomain"/>
    <add key="username" value="username"/>
  </appSettings>
</configuration>Update your “domain” and “username”.3. Add following code in Main method (usually in program.cs file)try
{
    using (DirectoryEntry de = new DirectoryEntry(@"LDAP://" + ConfigurationSettings.AppSettings["ADDomain"]))
    {
        using (DirectorySearcher adSearch = new DirectorySearcher(de))
        {
            adSearch.Filter = "(sAMAccountName=" + ConfigurationSettings.AppSettings["username&…

Search User on Active Directory

If you know first or last name or both, you can look it up in active directory for details (such as email/title/phone etc)Simply create a shortcut on your desktop and point it to following:%SystemRoot%\System32\rundll32.exe dsquery,OpenQueryWindowNow double click the shortcut and search!

Recycle Application Pool using Command Line

IIS 6 uses different management scripts than IIS 7.This is important to note as all your target environments may not have same version of IIS.To recycle Application Pool in IIS 6, use the following script (in .bat file):@set apppool=SharePoint - testportal.mycompany.com80
cscript.exe %windir%\system32\iisapp.vbs /a "%apppool%" /rTo recycle Application Pool in IIS 7, use the following:@set apppool=SharePoint - testportal.mycompany.com80
%windir%\system32\inetsrv\appcmd recycle apppool /apppool.name:"%apppool%"Make sure there is no space between “apppool.name:” and "%apppool%" otherwise you’ll receive an error.

Enumerate through all href using jQuery – Update all URLs on page using jQuery

I first tried doing the following:$.each($('a'), function (index, value) {
                alert($('a')[index]);
            });Well, the above code works and gives you the absolute URLs, however, you can’t make any change to the anchor tag itself, which is why most likely you are enumerating. Therefore, I rewrote the code as follows:$('a').each(function () {
   alert($(this).attr('href'));
});You can clearly see, this is indeed the right way to go!

Using Delegation Control (such as AdditionalPageHead or SmallSearchInputBox) to add headers (scripts, styles etc) in MOSS 2007 sites

This is an easy way to add control across all the sites/pages in MOSS (whether system or other templates provided by Microsoft).These can be used in your custom layouts/ Master Pages as well.More on DelegationControl is here. Note that WSS 3.0 and SharePoint 2010, both provide this useful control.Scenario: Let’s say you have to add a JavaScript on all the pages in all SharePoint sites. The easiest way to do it would be using DelegateControl. AdditionalPageHead is one of the controls provided by Microsoft in the SharePoint Master Pages. Let’s see how we can use this.1. Open Visual Studio 2008 and select “SharePoint” in the group (this should be there if you have VSeWSS installed) and create “Empty” project named “MyProject”.2. Add a class MyControl and inherit it from “System.Web.UI.WebControls.WebControl”.3. Implement the method “OnLoad” like the following:using System.Web.UI.WebControls;namespace MyProject
{
    public class MyControl: WebControl
    {
        …

Enable Debugging in the VSeWSS with Visual Studio 2008 and MOSS 2007

Go to the application you are deploying your feature to, and open web.config and make following changes in the given sections (CustomeErrors, compilation and SafeMode sections are already there):<customErrors mode="Off" />
<compilation debug="true"…
<SafeMode CallStack="true"…Now press F5 and it should start debugging your projects/features/solutions created with VSeWSS.

VSEWSS - The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'."

I faced this issue after installing VSeWSS (Visual Studio Extensions for Windows SharePoint Services) V1.3. O/S was Windows Server 2003 SP2 and I was trying to package my solution for SharePoint in Visual Studio 2008 when it kept failing by giving following errors:“The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'.""and (at times when I was trying different things) the following error:“The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'.”Do the following to resolve, go to (try after each step in order): 0. If you are using domain account, make sure you are connected to that domain otherwise user (against which the VSeWSS site application pool is running) will not be able to authenticate.1. Follow this article and make sure IIS enables NTAuthenti…

Microsoft.com is blocked/ won’t open in my Windows Server 2003, all other websites are opening…

I started my old VM to configure MOSS 2007 on it and to my surprise, the site www.microsoft.com was not opening. Rest of the websites were opening just fine. Here is the solution:Go to: Start > Run > (type) “services.msc” (which opens the services mmc) > Now stop the “DNS Client” service. Now open www.microsoft.com in browser and it should open just fine!Weird enough. :)

401 Unauthorized Access Denied in MOSS 2007 when using hostname/ host header – Cannot Login on MOSS site

For a short assignment, I had to jump back to MOSS 2007 and while setting up the MOSS environment on Windows Server 2003, I came across a showstopper which I didn’t face before. When create a site collection and specify a host header for it, it doesn’t let you login no matter what (Even if you are 100% sure that the credentials are correct). Anyways. I was lucky that others have faced the same problem and figured out that it was due to Service Pack on Windows Server 2003.Solution:Follow these steps*:Click Start, click Run, type regedit, and then click OK. In Registry Editor, locate and then click the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\LsaRight-click Lsa, point to New, and then click DWORD Value. Type DisableLoopbackCheck, and then press ENTER. Right-click DisableLoopbackCheck, and then click Modify. In the Value data box, type 1, and then click OK. Quit Registry Editor, and then restart your computer.*Thanks to Koen who gave this simple so…