Saturday, October 23, 2010

Extract Assembly DLLs from GAC

Want to access GAC assembly folder's file system (say for Copying a DLL). Here is the shortcut to copy/extract GAC assemblies:

Go to Start >> Run >> type "c:\windows\assembly\gac_msil"
Extract Assembly DLLs from GAC
Now, You can get the GAC Files in File system. You can Extract the DLLs from here.
copy extract gac assemblies


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Wednesday, October 13, 2010

Creating Custom Menu with Sub-Menus under Site Actions in SharePoint

We can add custom menu in site actions with our most accessed URL's like "Quota Increase", "Owner change", etc. like the below screen.

But, Why we need to do this?
  1. Well, It's a good user friendly addition, they don't need to search for a link to raise a quota increase or ownership change or etc.
  2. Security trimming - This will avoid incorrect persons raising the request and rejections.
  3. Mistyped URLs – This will avoid  wrong URL's being entered.  On clicking the link, we can direct them to the request form with auto filled URL's of the site.
Creating custom menu with sub menus under site actions

Here is the code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint;

namespace Crescent.SharePointSupport
{
public class SiteActionsMenu : WebControl{
protected override void CreateChildControls()
{
SPContext.Current.Site.CatchAccessDeniedException = false;
base.CreateChildControls();
try{
SPContext.Current.Web.CheckPermissions(SPBasePermissions.ManageSubwebs);
//MenuItemTemplate siteCollSettings =
//GetNewItemTemplate("Top Level Site Settings", "/_layouts/settings.aspx", "/_layouts/images/crtsite.gif", "Manage site settings for top level site.");
//siteCollSettings.Sequence = 399;
//this.Controls.Add(siteCollSettings);
}
catch (UnauthorizedAccessException)
{
// Do nothing}
AddSharePointSupportMenus();
}


private void AddSharePointSupportMenus()
{
try{
SPContext.Current.Web.CheckPermissions(SPBasePermissions.ManagePermissions);
}
catch (UnauthorizedAccessException)
{
return;
}

SubMenuTemplate userAndPermissions = GetNewMenuTemplate("SmartTools.EnhancedSiteActions.UserAndPermissions", "SharePoint Support", "Access SharePoint Support Links.", "/_layouts/images/menuprofile.gif", 402);

string url = string.Format("{0}/_layouts/people.aspx", SPContext.Current.Web.Url);
MenuItemTemplate peopleAndGroups = GetNewItemTemplate("Quota Increase", url, "/_layouts/images/PPEOPLE.GIF", "Raise a Request for increasing the site quota.");
userAndPermissions.Controls.Add(peopleAndGroups);

url = string.Format("{0}/_layouts/user.aspx", SPContext.Current.Web.Url);
MenuItemTemplate advPerm =
GetNewItemTemplate("Ownership Change", url, "/_layouts/images/menupersonalize.gif", "Raise a request to change the site owners.");
userAndPermissions.Controls.Add(advPerm);


url = string.Format("{0}/_layouts/user.aspx", SPContext.Current.Web.Url);
MenuItemTemplate Deletesite = GetNewItemTemplate("Request to delete Site", url, "/_layouts/images/manageuser.gif", "Raise a request to delete the current site.");
userAndPermissions.Controls.Add(Deletesite);

url = string.Format("{0}/_layouts/user.aspx", SPContext.Current.Web.Url);
MenuItemTemplate ChangeURL =GetNewItemTemplate("Request to change Site URL", url, "/_layouts/images/LISTSET.GIF", "Raise a request to change the current site's URL.");
userAndPermissions.Controls.Add(ChangeURL);

url = string.Format("{0}/_layouts/user.aspx", SPContext.Current.Web.Url);
MenuItemTemplate Genquery =GetNewItemTemplate("General Query to Support", url, "/_layouts/images/menuprofile.gif", "Send a question to SharePoint Support.");
userAndPermissions.Controls.Add(Genquery);

url = string.Format("{0}/_layouts/user.aspx", SPContext.Current.Web.Url);
MenuItemTemplate FAQLinks =GetNewItemTemplate("Frequently Asked Questions(FAQ)", url, "/_layouts/images/NEWSPG.GIF", "Access Frequently asked questions section");
userAndPermissions.Controls.Add(FAQLinks);

url = string.Format("{0}/_layouts/user.aspx", SPContext.Current.Web.Url);
MenuItemTemplate Learning =
GetNewItemTemplate("SharePoint Learning", url, "/_layouts/images/Home.gif", "Access SharePoint Learning section");
userAndPermissions.Controls.Add(Learning);
 

this.Controls.Add(userAndPermissions);
}

private static MenuItemTemplate GetNewItemTemplate(string text, string url, string imageUrl, string description)
{
MenuItemTemplate item = new MenuItemTemplate();
item.Text = text;
item.ClientOnClickNavigateUrl = url;

item.ImageUrl = imageUrl;
item.Description = description;
return item;
}

private static SubMenuTemplate GetNewMenuTemplate(string id, string text, string description, string imageUrl, int sequence)
{
SubMenuTemplate menuTemplate = new SubMenuTemplate();
menuTemplate.Text = text;
menuTemplate.Description = description;
menuTemplate.ID = id;
menuTemplate.ImageUrl = imageUrl;
menuTemplate.Sequence = sequence;
return menuTemplate;
}
}

Don't forget to add a safe control entry.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Sunday, October 10, 2010

Manage Blocked File Types in SharePoint

Recently another user came to me saying, He got the below error while he tried uploading a file to SharePoint:

"The following file(s) have been blocked by the administrator"

This is because: The user tried uploading .OCX files, which were in the blocked file type. Here is what I did to allow the OCX files. Blocked File types option in SharePoint is a great security/governance feature.  You don't want your users to upload executable or Movie files to SharePoint libraries, Isn't it?

Unblocking Blocked File Types: Manage blocked file types SharePoint
  • Open central administration site.
  • Go to Operations tab.
  • Find a section named "Security Configuration".
  • Under this section, you can find a link for "Blocked file types".
Blocked File Types in SharePoint
Select the Web Application that you would like to modify from the drop down list
remove blocked file types sharepoint
You will now have a large list showing all of the blocked file extensions, allowing you to add and remove them from the list. In this case you want to allow OCX files so they could shared through SharePoint, Just Remove the file type OCX and click "OK".

Configuring Blocked File Types in SharePoint 2010

For SharePoint 2010, You can navigate to: Central Adminstration >> Security >> Define blocked file types.

Change blocked file types SharePoint 2010 
Define Blocked File Types
Is SharePoint blocking Files Based on File Extension or actual file type?
Remember, SharePoint blocks file based on its extensions and not by the actual file type. Which means, You can rename the blocked file type (E.g. Rename "Program.exe" to "Program.txt") and still upload them to SharePoint. To mitigate, you need to have Forefront Security for SharePoint, which can block files based on its type and not just extension.

SharePoint blocked file types global list

Blocked file types Central are configured in Central Administration, are applied per web application, not globally throughout your farm. Internally, SharePoint keeps a file in 14 hive (or 12 hive in MOSS 2007) Config folder docextflt.xml So, When you create a new web application, blocked files list getting populated from this xml file.

However changing this file will not affect any existing web applications created already. But this will impact the default blocked files list, when you create a new web application.
Glogal Blocked Files List docextflt.xml

Manage SharePoint blocked file types with PowerShell.

Write-host "Enter the Web Application URL:"
$WebAppURL= Read-Host
$WebApplication = Get-SPWebApplication $webAppURL
$Extensions = $WebApplication.BlockedFileExtensions
#SharePoint list blocked file types  
write-host "Blocked File Types:"
$Extensions | ForEach-Object {Write-Host $_}

#To Add a Blocked File type
$Extensions.Add("dlg")
$WebApplication.Update()
write-host "DLG File type has been Blocked"

#To Remove a Blocked File type
$Extensions.Remove("dlg")
$WebApplication.Update()
write-host "Blocked File type DLG has been Removed"

You can remove Blocked File Types in SharePoint Object Model(C#) programmatically:
Collection<string> be = webApplication.BlockedFileExtensions;
if (be.Contains("ocx")) be.Remove("ocx");
webApplication.Update();

For reference:  SharePoint 2010 default blocked file types:
ade
adp
app
asa
ashx
asmx
asp
bas
bat
cdx
cer
chm
class
cmd
cnt
com
config
cpl
crt
csh
der
dll
exe
fxp
gadget
grp
hlp
hpj
hta
htr
htw
ida
idc
idq
ins
isp
its
jse
ksh
lnk
mad
maf
mag
mam
maq
mar
mas
mat
mau
mav
maw
mcf
mda
mdb
mde
mdt
mdw
mdz
msc
msh
msh1
msh1xml
msh2
msh2xml
mshxml
msi
msp
mst
ops
pcd
pif
pl
prf
prg
printer
ps1
ps1xml
ps2
ps2xml
psc1
psc2
pst
reg
rem
scf
scr
sct
shb
shs
shtm
shtml
soap
stm
svc
url
vb
vbe
vbs
ws
wsc
wsf
wsh

Technet Article: http://technet.microsoft.com/en-us/library/cc262496.aspx

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Tuesday, October 5, 2010

List Aggregation-Rollup across site collections (Even across Farms) using Dataview, Web Services in SharePoint

With SharePoint web services and dataview web part, You can aggregate the lists/document libraries/etc between sub-sites/site collections/web applications/even across forms.

So, Here I'm going to walk through how to achieve this using a simple example. Lets say I've two sites namely:  Site1  and Site2 and I've a Announcement List 1 in Site 1 and Announcement List 2 in Site2.

Now, What I want to create is: in my portal, I would like to create a consolidated view which has both the announcements from site 1 and site2. Follow the below steps.

1. Open the SharePoint designer and Create a Aspx page
list aggregation sharepoint

2. Go to Dataview >> Click on "Manage data sources"
list aggregation sharepoint 2007
3. Expand the "XML Web Services" node in Data source Library" and click on Connect to a web service

4.  Enter the web service URL:  http://sitename/_vti_bin/lists.asmx , click on "Connect Now" then, select the GetListItems Method. Enter the List Name. Supply the Login parameters.
Specify the web service URL and pick: GetListItems operation.

5. Do the same for all other lists you would like to connect. Finally you will have the data sources like this:
sharepoint list rollup

6. Now expand the "Linked sources" in data source Library and add the web services sources you have created.
List rollup SharePoint

7. Insert a dataview into the Aspx page you created.
 sharepoint cross list rollup

8. Drag and Drop the z:row From Linked source to Dataview webpart.
Combine List Data in SharePoint

 9. Finally you will get the merged data.
Merge Data from Multiple Lists SharePoint
10. Do the cleanup, change the column headers, apply the master page, Filters!

Here is my another post on comparing third party tools for the same purpose:
List Aggregation/Rollup In SharePoint -Third Party Products Comparison

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Saturday, October 2, 2010

Add Favicon for SharePoint sites

What is FavIcon? Favicon appears next to the URL in the address bar and in bookmarks menu next to the site name will show with the icon. In SharePoint Favicons are good way to add some additional branding to SharePoint sites.
sharepoint 2010 branding favicon

How to create a FavIcon?
Simple. Take your company logo or image, convert it to .ICO format, upload to Images folder in 12 or14 hive, Edit the master page.

you can try the free sites to create your favIcon as well:
  1. http://tools.dynamicdrive.com/favicon/
  2. http://www.favicon.cc/

Here are the detailed steps to add FavIcon in SharePoint:
Copy the favicon.ico file in your SharePoint WFEs "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\" or you can upload to a SharePoint library even. For SharePoint 2013, FavIcon located at: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\IMAGES
Add FAV Icon in SharePoint 2010

Edit the master page (typically default.master or V4.master):
For SharePoint 2010: Find and update this code:  
<SharePoint:SPShortcutIcon ID="SPShortcutIcon1" runat="server" IconUrl="/_layouts/images/myfavicon.ico"/>


You can edit the master page using SharePoint Designer to change favicon or you can directly edit it from File system: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\V4.master

In case you are uploading your icon to a sharePoint library, then change the path to: <SharePoint:SPShortcutIcon ID="SPShortcutIcon1" runat="server" IconUrl="<% $SPUrl:~SiteCollection/Style%20Library/Images/myfavicon.ico %>"

In some browsers you may need to place the <link rel="shortcut icon" href="/_layouts/images/myfavicon.ico" />  attribute right before </head> tag.

For SharePoint 2007: Change favicon
To Change Favicon in SharePoint 2007, Right before the closing head tag, add the following line :

    <link rel="shortcut icon" href="/_layouts/images/myfavicon.ico" />

Do IIS reset, clear browser cache/temporary internet files. Close the browser and reopen then browse the SharePoint site.
    
That's all!

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


You might also like:

Related Posts Plugin for WordPress, Blogger...