Brijesh's profileBrijesh's spacePhotosBlogLists Tools Help

Blog


    August 07

    How to create dedicated content database for a site collection:

    Steps to create a new site collection in a new content database:

    Let’s assume that I want to create a new dedicated content database for a new site collection. This site collection will have huge contents and it may require database of size 60-80 GB. Also we do not want any of the content databases to grow more than 100 GB (Microsoft recommended content database size). So we decided to create a new dedicated content database for this site collection. Any new site collection after this must be created in a content database with a least number of sites in it, provided it is not crossing the limit of maximum allowed sites in that content database. 

    As usual, I have taken few screen captures for better understanding of this scenario.

    We have total 8 content databases for our MOSS 2007 deployment. I have created a new content database with the name “New_Content_DB”.

    I want to create a new site collection in this new content database – “New_Content_DB” and then lock it. So that any new site collection after this will be created in a content database (any one from SPS01 to SPS08) with least number of sites in it. Let’s create a new site collection,

    New site collection – “sites/newsc” was created in “New_Content_DB” as expected. Now, I would like to lock it so this content database will be used only for this site collection – “sites/newsc”.

    I ran following query to confirm that the site collection – “sites/newsc” was created in “New_Content_DB” database.

    Now, let’s lock it. I have set “Site Level Warning” to 0 and “Maximum Number of Sites” to 1 for this. Here is the screen capture,

    Any new site collection after this must be created in content database with least number of sites in it. In our case it is SPS07. So let’s create a second site collection and it must be created in SPS07 instead of New_Content_DB. Here is the screen capture,

    As shown below, the second site collection – “sites/newsc2” was created in SPS07 database.

    One more time, SQL query to confirm that second site collection – “sites/newsc2” was created in SPS07 database.

    Any new site collection after this point will be created in SPS07 and then SPS08 and so on…Here is the screen capture after creating couple of other site collections – “sites/newsc3”, “sites/newsc4” etc.

    As per Microsoft recommendation SharePoint content database should not grow more than 100 GB in size. So you may want to move site collections with maximum contents or fastest growth from one content database to another (the smallest content database in your SharePoint farm or a new content database). Here are the few support links which can help you achieving this.

    For SharePoint 2007:

    First Release of the Microsoft SharePoint Administration Toolkit:
    http://blogs.msdn.com/sharepoint/archive/2008/04/30/announcing-the-first-release-of-the-microsoft-sharepoint-administration-toolkit.aspx

    Mergecontentdbs: Stsadm operation:
    http://technet.microsoft.com/en-us/library/cc288557.aspx

    One of the best posts for moving site collections to another content database:
    http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?List=56f96349-3bb6-4087-94f4-7f95ff4ca81f&ID=53

    For SharePoint 2003:

    MS IT Database Split for WSS2.0 and SPS2003:
    http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=governance&ReleaseId=5351

    August 01

    Audience Targeting Vs. Security

    Audience Targeting:

    MOSS 2007 has a feature that allows you to enable audience targeting (although this is not available in WSS 3.0). Turning on this feature means any items in a list or library can be set to appear only for a particular audience. An audience can be defined as a SharePoint group, distribution list, security group, or a global audience. The advantage of this feature lies in showing a group of users only relevant information, as opposed to overwhelming them with less relevant information. For example, a company may have a list of all new employees, perhaps including some trivia and background information. Audience targeting permits administrators to show a list of only those employees that joined a particular business unit, and only the primary identification information. The disadvantage of audience targeting is that users are not prevented from seeing the entire list, by selecting a different view or URL hacking, unless item-level security is applied.

    Item-Level Security:

    This feature enables users to set specific security on each item in a list or library. This means that, as items are added to the library, the user can indicate who can view the item. When setting the security for a single item, SharePoint allows the user to give access to an individual or group within AD and/or SharePoint. Item-level security is useful when uploading specific documents that only certain users should be able to see and completely prevent others from accessing them. For example, an internal portal for a company could display employee benefits only to that specific employee. Item-level security could allow only those users to see those documents without making the same documents available to the entire company.

    The disadvantage of item-level security is the headache it poses for administrators in cases where it is unclear who the intended viewer is. For users of the older SharePoint Portal Server 2003, item-level security is not ideal given that users could see all items in a list, and only discover upon clicking whether they were authorized to view the item. SharePoint 2007 has now updated this feature with security trimming: Users see only the items listed that they are authorized to view, and all other items are filtered, or "trimmed" out.

    Reference:
    http://www.developer.com/tech/article.php/3722456

    July 31

    AD Groups and SharePoint Groups

    Choosing between AD Groups and SharePoint Groups. What is the best approach for assigning permission levels in SharePoint?

    Here are some guidelines:

    A general rule of thumb is the less security principals you have, the more scalable your security design will be.  In other words, it is easier to assign permission levels to 1 group than 100 users.

    Avoid assigning permission levels directly to user accounts—use either an Active Directory (AD) group or a SharePoint group to contain the users.  If there is a one-to-one mapping between an AD group and a SharePoint permission level, you could assign permissions to the AD Group rather than creating a SharePoint group, but if you always use a SharePoint group, you have a clean way to add more users/groups later if you need to.

    Use SharePoint groups over AD security groups.   You can delegate control of SharePoint groups to site administrators.  If you use AD groups, there could be a bottleneck getting users added/removed from them since only a select few in the organization have permissions.  Another issue with AD groups is you cannot view the members in SharePoint, making it difficult to determine who has access to what.

    Difference between SharePoint Groups and AD Groups:

    Domain Groups

    •       Normally created and maintained by the IT department
    •       Can be used across different SharePoint sites and site collections
    •       Organizations may already have good AD group structures that map well to your SharePoint implementation
    •       Groups can be nested - e.g. you can add another AD Group as a member to an existing AD group
    •       No features for users to submit a request to join a group

    SharePoint Groups

    •       The creation of groups can be done by business users
    •       When a group is being created, you can define who "owns" the group
    •       Can allow users to submit a request to join a group
    •       Can determine who has permissions to see the users within groups
    •       Groups are created within a particular Site Collection - cannot be used in other site collections
    •       You cannot add a SharePoint Group as a member of another SharePoint group (no nesting)
    •       SharePoint Groups cannot be used in other systems (e.g. network Shares)
    •       The SharePoint Groups are separate from Active Directory - so you can go wild with the SharePoint Groups without upsetting your AD administrator

    References:
    http://www.sharepointblogs.com/johnwpowell/default.aspx
    http://guru-web.blogspot.com/2007/10/difference-between-sharepoint-and-ad.html

    July 30

    Increase size for incoming e-mails in SharePoint

    Recently we had an issue for receiving emails with larger file attachments in SharePoint. Here is how we fixed this issue.

    Note: We have maximum email size set to 10 MB in MS Exchange. So MS Exchange will not allow any emails bigger than 10 MB. Also default setting for maximum email size in SMTP Virtual server is 2 MB.

    Steps to modify SMTP Virtual Server properties and increase incoming email size limit to accept bigger emails in SharePoint.

    1. Open IIS on SharePoint Server where SMTP Virtual Server is hosted.

    2. Right click on Default SMTP Virtual Server and select properties.

    3. Click on "Messages" tab of Default SMTP Virtual Server Properties.

    4. Change "Limit message size to(KB)": 10240

    5. Change "Limit session size to(KB)": 51200

    6. Click "Apply" and then "OK" button at the bottom.

    - We can NOT increase this limit more than 10 MB (10240 KB) because this is the maximum email size allowed in MS Exchange.

    - You will not be able to receive emails bigger than 10 MB even by setting this limit to 20 MB or more. (Provided you have maximum email size set to 10 MB in MS Exchange Server of your company).

    SQL queries for analyzing SharePoint farms

    =====================================================
    Query to get total number of items in each list of SharePoint farm:
    =====================================================

    Use SP_DB01

    select

    case when webs.fullurl = ''

    then 'Portal Site'

    else webs.fullurl

    end as [Site Relative Url], webs.Title As [Site Title],

    case tp_servertemplate

    when 104 then 'Announcement'

    when 105 then 'Contacts'

    When 108 then 'Discussion Boards'

    when 101 then 'Docuemnt Library'

    when 106 then 'Events'

    when 100 then 'Generic List'

    when 1100 then 'Issue List'

    when 103 then 'Links List'

    when 109 then 'Image Library'

    when 115 then 'InfoPath Form Library'

    when 102 then 'Survey'

    when 107 then 'Task List'

    else 'Other' end as Type, tp_title 'Title', tp_description As Description, tp_itemcount As [Total Item]

    from lists inner join webs ON lists.tp_webid = webs.Id

    Where tp_servertemplate IN (104,105,108,101, 106,100,1100,103,109,115,102,107,120)

    order by tp_itemcount desc

    Note: Repeat above query for each SharePoint content database.

    ==========================
    Query to find all site collections:
    ==========================

    Use SP_DB01

    Select SiteId, FullUrl, Title, Author, TimeCreated
    From Webs
    Where ParentWebId IS NULL

    Note: Repeat above query for each SharePoint content database.

    =======================================================================================
    Query to get Site Collection Statistics - Created, Owner, Contents size, Bandwidth usage, Last Modified etc.
    =======================================================================================

    Use SP_DB01

    select distinct a.fullurl as [SiteUrl], a.TimeCreated as Created,

    b.tp_login as [SiteAdmin],

    sum(cast(c.size as decimal))/1024/1024 as [recyclebin],

    cast(d.bwused as decimal)/1024/1024 as [BandwidthUsed],

    cast(d.diskused as decimal)/1024/1024 as [SiteSize],

    cast(d.diskquota as decimal)/1024/1024 as [SiteMaxQuota],

    d.id as [SiteID],(select db_name(dbid) from master..sysprocesses where spid=@@SPID) as [Content_DB],

    (select @@servername) as [ServerName],

    d.lastcontentchange as [LastContentChange],

    (select datediff(day,d.lastcontentchange,current_timestamp)) as [DaysSinceLastChange]

    from webs as a inner join  

                sites as d on a.siteid=d.id inner join

           userinfo as b on a.siteid=b.tp_siteid left join

             recyclebin as c on a.siteid=c.siteid where b.tp_siteadmin = '1' and a.parentwebid is null   

    group by a.fullurl, b.tp_login, d.diskused, d.id, d.bwused, d.diskquota, d.lastcontentchange, a.TimeCreated

    Order by a.fullurl

    Note: Repeat above query for each SharePoint content database.

    References:
    http://blogs.technet.com/corybu

    http://www.codeplex.com/MSITSRF
    http://www.codeproject.com/KB/dotnet/QueriesToAnalyzeSPUsage.aspx


    June 18

    How to add SharePoint search to Internet Explorer 7.0?

    • Click drop down menu on the right hand side of “Glass” icon and select “Find More Providers…” in IE 7.0

    clip_image002

    • Under “Create Your Own” enter URL and Name. Please make sure you search for TEST (k=TEST) in URL. For example,

    URL:
    http://sharepoint.domain.com/sites/TestSC/SearchCenter/Results.aspx?k=TEST&s=All%20Sites

    Note: Above URL is for searching in "All Sites" (in entire SharePoint Server Farm).

    Also note that I have specified "SharePoint Search" as the name of the search provider.

    clip_image004

    clip_image006

    • Click “View” link, if you want to look at the XML file, click “Install” button otherwise, which will add this custom search provider to IE 7.0

    clip_image008

    • Once the Search Provider will be added, you will see it listed in Search Engine List.

    clip_image010

    • Search for something, let’s say “sharepoint” and select “SharePoint Search” – the custom search provider, which we have added in previous steps. It will ask you for credentials to connect to the SharePoint site. Enter your credentials and it will return search results.

    clip_image012

    clip_image002[4]

    June 12

    How to configure Records Center in Microsoft Office SharePoint Server 2007

    In this post, I will walk you through the steps for configuring Records Center site in MOSS 2007. Luckily, Records Center Site template is available with both Standard and Enterprise Edition of Microsoft Office SharePoint Server 2007.

    Let’s start with understanding the purpose of setting up Records Center site. Why do we need central repository for our contents? Well, you can store almost all kind of contents in SharePoint but if you will not manage it properly, SharePoint contents will grow tremendously and eventually it will go out of control. The only way to prevent SharePoint servers from deteriorating in the future with an overload of content is to start archiving unwanted information. This is done by linking live or active SharePoint sites to a Record Center.

    I am going to create a new site collection for Records Center in my existing SharePoint server farm however it is possible to create a Records Center in a separate farm and link it to SharePoint sites in this farm. In fact, that would be a better approach as you will be moving unwanted SharePoint contents to the content databases of another farm which will help you in keeping your live or active SharePoint farm content databases as small as possible.

    Here are the steps:

    1. Create Records Center site.

    2. Create library for storing archive contents from SharePoint live sites.

    3. Create and apply Information Management Policy for the retention period.

    4. Define Record Routing rule for the content type.

    5. Configure Record Center from SharePoint Central Administration site.

    6. Start archiving unwanted SharePoint contents.

    · Create a new site collection for Records Center.

    · I have named it “Records Center Site”.

    · Here is the Records Center site out of the box. In this example, we will configure Record Center site to archive project documents from live or active SharePoint site - “Test Site Collection”. Create a new document library for unwanted project records (documents).

    · I have named it “Project Documents Repository”. Please note that I have selected “None” in Document Template as my project document could be a word, excel or any other document.

    · Define policy for the retention period. Click “Site collection policies” link under Site Collection Administration.

    · Create a new policy. Click “Create” link on the top right corner.

    · I have named it “Project Document Policy”. I have selected all auditing options to keep the track of any changes in these documents. I have selected 5 years retention period for these documents after they are last modified. They will be deleted after 5 years.

    Note: Records (documents) older than 5 years will be deleted and sent to “Recycle Bin”. Records Center administrator will then decide to delete them permanently. If there is a need, administrator can restore documents from recycle bin.

    · Site collection policy is successfully created.

    · Apply policy “Project Documents Repository” document library. Click “Information management policy settings” link under Permissions and Management.

    · Select “Use a site collection policy” option and apply “Project Document Policy” , which we created in previous steps.

    · Set same Meta data for this document library - “Project Documents Repository”. This is because when you archive contents from live SharePoint site, it will be stored here and that’s why it is good to have same Meta data as document library of live SharePoint site. Click “Add from existing site columns” link under Columns.

    · Add all those columns (properties), which you have for your live document library contents.

    · I have also modified “All Documents” under Views to show these Meta data in default view.

    · Here is how “Project Documents Repository” looks like after following above steps.

    · Create “Record Routing” to archive project documents in “Project Documents Repository”. Click New => New Item under Record Routing.

    · I have used “Project Content Type” for creating project documents in my live site – Test Site Collection. Record Routing title will be the content type which you want to archive from live SharePoint site. So in title I have “Project Content Type”. Location will be the name of the document library where you want to route these records. In our case it is “Project Documents Repository”.

    · Everything is set in our Records Center and here is how it looks like after following above steps.

    Note: If you have not specified Records Routing properly, it will route all the documents to “Unclassified Records” document library using default “Unclassified Records” routing when you archive them from SharePoint live sites.

    · Now, configure Record Center from SharePoint Central Administration site. Go to Application Management and click “Records center” link under External Service Connections.

    · Provide the URL of the Records Center site appended with /_vti_bin/officialfile.asmx as shown in example. I have used display name as “Records Center”. So when somebody will right click on document to be archived, he/she will see “Send To => Records Center” in the menu.

    URL: http://sharepoint.domain.com/sites/RC/_vti_bin/officialfile.asmx

    Display Name: Records Center

    · That’s it. You have successfully configured Records Center. Now, let’s test it. As shown below, I am going to archive one of the documents from “Project Document Library” of my live site – “Test Site Collection”. Right click on the document to be archived, select “Send To => Records Center”.

    · If you have followed all above steps properly, you will see “Operation Completed Successfully” message.

    · Document will still remain in the document library of your live site. You may delete it as it has been stored in Records Center already and it is not needed any more.

    · Let’s go back to Records Center site to check, if the document is successfully archived and yes, it is. It will create folder with the time stamp to store those archive documents.

    · In side the folder, you can see the document and the Meta data (properties) of that document. Properties are stored in the form of an XML file.

    There is lot more you can do with Records Center other than just moving archive contents however idea behind this post is just to give an overall idea of how Records Center site works.

    · Following screen captures explain how to copy accidentally archived document (if you have deleted it from everywhere – document library, recycle bin etc. in your live site) back to its original location. This has nothing to do with Records Center but I have added this just to give you an idea of copying document from one location to the other. Right click on document to be copied and click “Send To => Other Location”

    · Provide the destination URL.

    Destination document library or folder:

    http://sharepoint.domain.com/sites/TestSC/ProDL

    Also you can change the document name if you wish.

    · Click “OK” button at the bottom.

    · Document successfully copied to “Project Document Library” for Test Site Collection.


    Link to a Document content type, Add link to a document to announcement items and Meta data for folder contents

    In this post, I am going to talk about few interesting things. Let’s start with “Link to a Document” content type. I will also talk about best practices in SharePoint 2007 while I will go through these topics.

    1. Create a new document library. I am going to create document library for project documents.

    1. As shown below, I have named this document library as “ProDL” and entered “Project Document Library” as description.

    Note: It is a good idea to abbreviate your list or library name when you create them. This will help in keeping SharePoint URLs as short as possible. You can change the name of the document library to whatever you want later on by going to document library settings. Please keep going to learn how?

    1. Go to the document library settings of document library – “ProDL”, which you created in previous step. Click on “Title, description and navigation” link under General Settings

    1. You can change name here to whatever you want. I have changed it to full name – “Project Document Library” and that is what it will display as name for this document library in SharePoint but the URL for this document library will still use the abbreviated name – “ProDL”, which we entered at the time of creating it.

    1. As shown below, name appears as “Project Document Library” in SharePoint site.

    1. Click “Advanced settings” link under General Settings

    1. Select “Yes” for “Allow management of content types?” as shown below.

    1. After you finish step 7, you will be able to see “Add from existing site content types” link under Content Types. Click this link - “Add from existing site content types”

    1. Select “Link to a Document” content type and add it.

    1. After step 9, you should be able to see “Link to a Document” in “New” menu of your document library.

    1. Click “Link to a Document” under “New” menu.

    1. Enter “Document Name” and “Document URL” for the existing document at other location (in another document library).

    1. Here is how “Project Document Library” looks like after adding one document and one “Link to a Document” content.

    Note: Always use “Link to a Document” content type instead of adding the same document to another document library or the document library of another site.

    How to add link to the document to Announcements list?

    1. Go to Announcement Settings => List Settings as shown below.

    1. Click “Add from existing site columns” link under Columns.

    1. Select “Web Page” column and add it. Please make sure you have selected “Add to all content types” and “Add to default view” as shown below.

    1. That’s it. You are done. Now you can add link to a document when you add announcement items to Announcement list.

    1. Here is how Announcement list looks like after adding announcement items with link to a document.

    Finally let’s talk about Meta data for folder content type. Never use folders, always use views. It is NOT recommended to use folders in document library or any other list but there are certain situations where you may want to add folders and then Meta data for those folders.

    How can you add Meta data to folders?

    1. Go to Site Actions => Site Settings => Modify All Site Settings

    1. Click “Site content types” link under Galleries.

    1. Click “Create” link on top left corner.

    1. We are going to create folder content type for defining Meta data for folder contents. Please select the settings as shown below. You can add this new content type to “Custom Content Types” by choosing it under “Existing group” or you can create a new group.


    1. Go to the document library where you want to define Meta data for folder contents. Click Settings => Document Library Settings.

    1. Click “Advanced settings” under General Settings

    1. Select “Yes” for “Allow management of content types?” as shown below.

    1. After step 7, you will be able to see Content Types in document library settings. Click “Add from existing site content types” link under Content Types.

    1. Select “Folder Content” content type, which we have created in previous steps and add it.

    1. As shown below, “Folder Content” is now added to your document library. Click “Folder Content” link under Content Types.

    1. Add appropriate columns for your folder contents. I will add couple of columns by clicking “Add from existing site or list columns” link under Columns.

    1. I have added “Category” and “Release Date” columns as shown below.

    1. Now, it will allow me add Meta data whenever I create a new folder in this document library. Following screen shots show how to add Meta data to existing folders in your document library.

    1. Right click on folder and select “Edit Properties”.

    1. Select “Folder Content” (which is what we have created in previous steps), if you have more than one content type listed in drop down menu.

    1. Enter Meta data as shown below.

    1. Here is how document library looks like after adding Meta data for folders.

    June 07

    When to use a Site Collection over a Sub-Site

    When should you use site collections over sub-sites in your design?

    Site collections really bring a considerable amount of flexibility and scalability to your design and I would recommend that you start from the perspective of multiple site collections and then see if you can find logical and compelling reasons to move away from them.

    Here are some general guidelines that you should consider before you create a site collection or a sub site.

    Consider the core purpose of the site structure you are contemplating. Consider it in relation to the other site structures your portal may house. It is generally not advisable to intermingle disparate sites in the same site collection. For instance you probably would not want your Internet presence site and your collaboration portal to all be part on the same site collection. There are simply too many moving parts that are completely unrelated to one another to make this feasible. While this is a simple example you could consider something such as separating out department sites or even project sites. I do this a lot simply because HR may need a different approach to security than Finance.

    If distributed control is something that you want then multiple site collections would be the best way to go. Site collections really are the first layer where we can truly separate out security and administration. Although we can break security inheritance at the site level these still fall under a single umbrella or controlling entity, the site collection and its administrator. I see this a lot when it comes to those core department sites that any organization has. Many times Human Resources, Finance, IT, and Operations will be separated out into their own site collections to provide an additional layer of content control.

    Boundaries are a consideration as well. Some of the key components that make up a SharePoint site are scoped to the site collection level. While there are ways around these boundaries they should be accounted for in your design. The following is a list details some of these components.
     
    • Site Columns and Content Types
    • Site Quotas
    • SharePoint Security Groups
    • Recycle Bin
    • Site and List Templates and Master Pages
    • Search Scope and Keywords
    • Out-of-box Back up and Restore capabilities
    • Separate Content Databases
    If you have groups that cannot share resources they really need to be broken out into separate site collections. Governance can come into play here from the stand point that if the two groups should not have the ability to view or control one another's content then they should be separate or a single, and separate, entity should administer the site collection.

    Finally one of the biggest drivers for a separate site collection is security. The ability to place an entirely separate security structure around each site collection can be critical. Site collections can also be broken out into separate content databases which can offer an additional layer of security at the database.

    My general feel on this is to begin my design with multiple site collections in mind and then see if I can find a valid reason to deviate from that design. Sometimes the reason is there but more often than not I find that site collections simply bring too much to the table.

    Site Settings at Top Level Site or Site Collection:

    http://sharepoint.domain.com/sites/IT


    Site Settings at Sub Site:

    http://sharepoint.domain.com/sites/IT/WindowsTeamSite
    Or
    http://sharepoint.domain.com/sites/IT/UnixTeamSite

    Note: I have copied this post from Joe Shepherd's blog. Thank you very much Joe for such a great post!

    Other caveats of using MS Office 2003 with Microsoft SharePoint 2007 products

    I have already discussed caveats of using MS Office 2003 with Microsoft Office SharePoint 2007 products in my last post. Before I talk about the other caveats, I would strongly recommend you to go through following white paper,
     
     
    Issues:
     
    1. Unable to check out document from SharePoint document library for editing it in MS Office 2003.
    Error - "Edit Document' requires a Windows SharePoint Services-compatible application and Microsoft Internet Explorer 6.0 or greater."
     
    2. Internet Explorer crashes (stops responding) when you try to open an Office document in a SharePoint document library.
     
    Here is how you fix these issues,
     
    There is no need to remove any Office 2007 applications from your computer.
     
    Step 1: Repair Office 2003:
    1. Go to Start => Control Panel
    2. Double Click on "Add/Remove Programs"
    3. After this list populates, locate and click "Microsoft Office 2003 Professional Edition"  or any other version of Microsoft Office 2003.
    4. Click on the "Change" button
    5. On the window that appears, click on the button "Reinstall or Repair" and select "Next"
    6. Click on the radio button "Detect and Repair errors in my Office installation" then click "Install"
    7. A message will appear once the repair is complete.
     
    Step 2: Click this link to a hotfix file from Microsoft and select "Run" to install this hotfix:
    http://download.microsoft.com/download/f/5/1/f511cec6-d8c5-444e-bd76-5161b2a16c9f/office-kb938888-fullfile-x86-glb.exe
     
    Information about this hotfix can be found here:
    http://support.microsoft.com/default.aspx/kb/938888
     
    Additionally, you may refer to following KB article if above steps do not resolve your issue,
     
    Note: Above issues may occur with MS Office 2007 applications (Word, Excel, PowerPoint etc.) too. You need not to uninstall any MS Office 2007 applications in order to resolve them.
     
    We do not have MS Office 2007 available yet so all above issues were reported while using MS Office 2003 with Microsoft Office SharePoint Server 2007.
    June 06

    Content types in Microsoft Office SharePoint Server 2007 and MS Office 2003

    Let’s talk about custom content type in Microsoft Office SharePoint Server 2007 and how it works with MS office 2003. To help visualizing this, I have taken screen captures for every little step.

    1. Create a custom content type for your test site. I am going to use “SCTest” top level site (site collection) for the demo. Go to Site Actions => Site Settings and click on “Site Content Types” link under Galleries category.

    2. Click “Create” link on the top left corner of Site Content Type Gallery.

    3. Create a new site content type as shown below. I have chosen Document content type for simplicity. You can add this content type to “Custom Content Types” by selecting it for Group category but I have created a new group called “Test Group” to add this new content type. Please note that I have named new custom content type as “Project Release Documents”

    4. You will see following screen on adding a new custom content type. Click “Add from existing site columns” link under “Columns” category.

    5. Add appropriate columns for this new content type. I have chosen few as shown below.

    6. This is how a new custom content type looks like after adding few existing site columns.

    7. I am creating a new document library for “Test Site Collection” (SCTest) to use this custom content type.

    8. As usual, I have used shortest possible name for my document library to keep URL for this document library as short as possible. You can always change the “Name” field later on by going to Title, description and navigation under General Settings of document library settings.

    9. Go to Settings => Document Library Settings.

    10. This is an additional step. I have modified the document library name from TCTL (to keep URL short) to Test Content Type Library as by going to Title, description and navigation under General Settings

    11. Click “Advanced Settings” link under General Settings category.

    12. Select “Yes” for “Allow management of content types?” and click “OK”.

    13. Select “Add from existing site content types” link under Content Types.

    14. Select a new custom content type – “Project Release Documents” which you have created in previous steps as shown below.

    15. This is an additional step – I am changing order for content types and making “Project Release Documents” as default content type. Select “Change new button order and default content type” link under Content Types.

    16. Change the order and select number “1” for “Project Release Document” content type to make it default content type for this document library.

    17. So finally content types and columns for your document library will look something like this. Please adjust your column order by clicking on default view – “All Documents”.

    18. Now, something very interesting…how content types work with MS Office 2003. Well, keep reading…

    As you can see from the screen capture, “Project Release Documents” is the default content type for your document library. Click New menu and select “Project Release Documents” to add a new document (content) to your document library.

    19. You will see following message on your screen, if you have MS Office 2003 installed on your machine. Click “OK”

    20. It will allow you to use MS Office 2003 (Word 2003) to create a new document. As you have already noticed MS Office 2003 will not allow you add/edit metadata in Word application itself. Add some text to this document and click “Save” icon.

    21. Now, you can add those metadata properties for your document however I have noticed that couple of document properties is still missing…I don’t know why. I need to check it out later but anyways it will allow you to add metadata properties for your document using MS Office 2003 and that is what is more important.

    22. To add those missing metadata properties, I am going to right click on document in my document library and select “Edit Properties” link.

    23. Adding those missing metadata properties, which I could not see in MS Office 2003 for some reasons.

    24. Finally here is the document in document library which was created using custom content type and MS Office 2003.


    Now, here is the scenario for those unlucky people who can not work with content types using MS Office 2003.

    Note: This site belongs to different SharePoint test environment than the previous one.

    1. I have created ProjDocs document library and it has “Test Content Type” as default content type.

    2. Attempt to create a new document in ProjDocs document library. Same message will pop up, which is shown is previous screen capture before opening MS Office 2003 (Word 2003) for creating a new document.

    3. Unfortunately when you try to save this document, it will give you following error message. When you (keep) clicking on either “Yes” or “No” button, it will finally add this new document to ProjDocs but all metadata properties will be missing and you can not add metadata properties even by editing properties in SharePoint.

    4. Document “Test2” was added.

    5. Trying to edit metadata properties by right clicking “Test2” document in ProjDocs document library and selecting “Edit Properties” link.

    6. Unfortunately it does NOT allow adding those missing metadata properties.

    7. Here is the work around. If you want to create a new document, simply upload a new document and it will allow you to add those metadata properties but if you want to edit metadata properties of existing document unfortunately you have to download that document to your local computer first and then upload it back to edit/update its metadata properties. Here is the screen capture for uploading a new document to ProjDocs document library.

    8. Enter metadata properties for this document and you are done!

    9. Here is how ProjDocs document library looks like after uploading those two documents.

    Note: Error: 'length' is null or not an object is environment specific. It happened in our environment after we installed one of the hot fixes (http://support.microsoft.com/kb/935958) for resolving the other issue.

    Here is the hot fix for those who are unable to work with content types using MS Office 2003.

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;950292

    This hot fix also resolves issues to work with multiple content types using MS Office 2003.

    Note: I have taken screen captures from two separate SharePoint environments.

    Step 1-24 are from the enviornment, that does NOT have http://support.microsoft.com/kb/935958 hot fix applied and we can work with content types using MS Office 2003 without any issues.

    Step 1-9 are from the environment, that has http://support.microsoft.com/kb/935958 hot fix applied and for some reasons we are unable to work with content types using MS Office 2003 after applying that hot fix. We have to apply http://support.microsoft.com/default.aspx?scid=kb;EN-US;950292 hot fix to resolve errors explained in these steps but we will have MS Office 2007 available very soon so we have NOT applied it yet.

    June 05

    How to make "All Sites" scope available to a top level site created using "Team Site" template?

    One of my friends had an issue in making “All Sites” scope available to a top level site (site collection) created using “Team Site” template. So I thought of writing this blog. This post assumes that you have Microsoft Office SharePoint Server 2007 implemented in your environment.

    First of all, why “All Sites” scope is not available, when you create a top level site or site collection using “Team Site” template? Because team site template is designed for WSS site and WSS does not have enterprise search feature available by default. In other words you can search only within that site itself and cross site search will not be available. Cross site search or Enterprise search feature is available only for Portal Site templates. If you will create top level site using templates under “Publishing” category, you will have “All Sites” scope available.

    So here is how you can make “All Sites” scope available to a top level site, which is created using “Team Site” template. For simplicity, I have taken screen capture for everything right from creating a new site collection (top level site) using “Team Site” template to making “All Sites” scope available to it.

    1. Create a new site collection using “Team Site” template. We have created a new site collection called “SCTest”.

    2. Only “This Site: Test Site Collection” (Name of the site collection) scope is available by default and we would like to have “All Sites” scope available at this top level site.

    3. After you create top level site, create a new “Search Center” site for this top level site.

    Note: If you have 50 site collections and all those site collections are created using “Team Site” template then I would suggest you to create 50 “Search Center” sites – one for each and with the same name (for naming conventions), if you want “All Sites” scope available to all those top level sites.

    4. Here is “Search Center” site created for SCTest site collection.

    5. Now, you need to change search settings for SCTest site collection. So go to Site Actions=> Site Settings and click “Search Settings” link under Site Collection Administration.

     6. Choose “Use custom scopes. Display richer results using the following Search Center:” and provide URL to “Search Center” site. In our case it is “/sites/SCTest/SearchCenter/”

    7. Now, you can see “All Sites” scope is available to SCTest top level site.

     8. Additionally you may need to activate “Office SharePoint Server Publishing Infrastructure” by going to “Site Actions=>Site Settings” and clicking “Site Collection Features” link under Site Collection Administration category.

    9. You may also need to activate “Office SharePoint Server Publishing” feature by going to “Site Actions=>Site Settings” and clicking “Site Features” link under Site Administration category.


     
    That’s it! You are all set. You can start using “All Sites” scope for cross site search capabilities.
    May 23

    Unable to activate Office SharePoint Server Publishing Infrastructure from site collection features

     
    Issue: Unable to activate "Office SharePoint Server Publishing Infrastructure" from site collection features.

    We had "Office SharePoint Server Publishing Infrastructure" activated since beginning but for some reasons it was deactivated and when I tried to activate it, I received "Access denied" error.

    Note:
    We have followed Microsoft Guidelines for setting up administrative and service accounts.

    Solution:

    1. Open IIS Admin.
    2. Locate the Web Site for your MOSS web application.
    3. Go to the properties and select "Home Directory" tab.
    4. Make a note of Application Pool used for this web site.
    5. Expand Application Pools in IIS.
    6. Go to the properties of Application Pool, which you have noted in step 4 and select "Identity" tab.
    7. Make a note of the account used under "Configurable".
    8. Change the Application Pool identity to SharePoint Service Account - This is the same account, which you have used for installation of MOSS 2007.
    9. IISRESET
    10. Activate "Office SharePoint Server Publishing Infrastructure" from site collection features.
    11. Change the Applciation Pool identity back to the original (same account which you have noted in step 7).
    12. IISRESET.
    May 22

    Permission issues in SharePoint 2007

     
    Issue: Unable to access Spell Checker in Rich Text Editor of Content Editor web part.

    Your sub site has custom permissions (NOT inherited from parent site) and you have "Full Control" access to your sub site but you are unable to use Spell Checker in Rich Text Editor of Content Editor web part.

    Solution: Create a custom permission level and name it "Reader Plus" (or any other appropriate name) by copying "Reader" permissions and adding "Browse Directories" permission at top level site. Allow "Reader Plus" access to the account at top level site, which has this issue.

    Issue: Unable to access "Information management policy settings" from Document Library settings or List settings.

    You have "Read" permissions at top level site and "Full Control" permissions to your sub site but you are unable to access "Information management policy settings" from Document Library settings or List settings.

    Solution: Same As Above

    Note: These permission issues seem to be addressed in Service Pack 1 for SharePoint 2007 however I haven't got a chance to install Service Pack 1 in our SharePoint environment yet.
    May 20

    Crawl doesn't work and Query server is not responding; Search works only for old (crawled) contents

    We had this search issue in January' 2008 and here is the description,
     
    We have following three servers with MOSS 2007 STD deployed in SharePoint server farm,
     
    App01- Query Server
    App02 - Index Server (We are using this server as dedicated web front end computer for crawling)
    SPDBServer - SQL 2005
     
    Search was working fine till 01/05/2008 and it stopped working after this date only for new contents meaning search is still working fine for the old contents which were added before 01/05/2008 but not for new contents added after 01/05/2008.
     
    We have been working to find out reasons why did that happen? We have found following event ids on Query server,
     
    Event ID:10042 - A new query machine, 'App01', has been added to the query rotation based on changes to farm topology.
     
    Event ID:27745 -  The following information is part of the event: #50071: Unable to connect to the database SharePoint_Config on SPDBServer.  Check the database connection information and make sure that the database server is running..
     
    Event ID: 7888 - A runtime exception was detected. Details follow.
    Message: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - Not enough memory is available to complete this request)
     
    We had some database backup client issue on database server but after fixing that issue and rebooting all the three SharePoint servers, we noticed that crawl was not responding. Last incremental crawl, started on 01/05/2008 did not stop even on Monday (01/07/2008).
     
    We have incremental crawl scheduled at every 6 hrs. everyday and full crawl scheduled on every saturday.
     
    After coming back to work on Monday 01/07/2008, we tried search and noticed that it was working only for existing contents(added before 01/05/2008) and not for all the new contents, which were added after 01/05/2008.
     
    When we check Search settings, it says "Query server not responding" and we are unable to stop/pause the incremental crawl, which was started on 01/05/2008. Only way to stop that crawl is to stop Office SharePoint Server Search service from services.msc on both App01 and App02 server.When we stop the crawl this way and start it again, it goes on and on and never stops. We have tried to start both full and incremental crawl this way but that didn't help.
     
    Only resolution to this issue, I have found is to readd App01 - Query server to the farm from SharePoint Central Administration however I am still wondering, if that will fix our "Query Server not responding" error. As per our research, it seems few other people also have noticed this issue for some unknown reasons and if SharePoint doesn't have any operational errors, we can safely ignore them. Microsoft is aware of this isse and they are expecting to get this resolved in SharePoint 2007 Service Pack 1.
     
    I was also thinking of resetting all crawled contents and rebuilding the content index. I  was affraid, if resetting the crawled contents will not regenerate/rebuild the new content index. If crawl will not work after resetting the crawled contents then SharePoint search will be completely down and it will stop working even for old contents.
     
    Has anybody tried this KB?
     
    Can we move content index(search catalogs) from shared location to some other location on Query server and then try resetting crawled contents? Can we move content index back to its original location if resetting crawled contents will not generate a new content index or it will not propagate it to Query server?
     
    If above KB article gives us the flexibility of reusing content index in case of resetting crawled contents fails to build a new content index or propagating it to Query server, we would like to try it first before we can try readding Query server to the SharePoint server farm (Stop and then restart Office SharePoint Server Search service for Query server from SharePoint Central Admin)
     
    Does anybody know an appropriate solution to fix this issue? Search works only for old (Crawled) contents and not for new contents, Crawl never stops (hangs) and there is "Query server not reponding" message on search settings so basically it is not propagating the content index.

     
    Solution:
     
    Here is how we fixed this issue in our environment. This issue might be specific to our environment and this resolution may not work for similar issue in the other environment.
     
    - We noticed few memory leaks in SQL Server 2005. We(our Windows Server team with SQL Administrator) fixed those issues first however fixing memory leaks in SQL didn't help us to fix search issues in SharePoint and we still had "Query Server not responding" error in SharePoint and Search was not working.
     
    - We created a new location for content index propagation on Frontend Server, which is also a Query Server.
    Note: Do not move existing crawled contents from old propagation location to a new location manually. In fact, SharePoint does it automatically once you create a new location for content index propagation with the following command. It is strongly recommended that you start a "Full Crawl" after this to rebuild content index for updated contents.
     
    - Ran following command to propagate search index to the new location,
     
    stsadm.exe –o osearch –propagationlocation index file path
     
    Please allow some time to move existing content index from previous location to a new location. You may see few known events in event viewer while SharePoint is moving content index to a new location however you can safely ingnore them. Please check status on Search Administration (SSP => Search Settings) page and for Query Server response. You can start a Full Crawl after few minutes once you see Query Server starts responding in Search Settings.
    This has fixed our SharePoint search issue and it works fine now.

    - Hope this will help others to resolve similar issue. Please make sure you do not have any SQL Server issues before you troubleshoot it in SharePoint.
     
    References:

    Technet Post on this issue:
    May 08

    Incoming e-mail feature in SharePoint 2007

    I am pretty excited about enabling incoming e-mail feature in our SharePoint production environment in this week ends finally. We have really tested it thoroughly in our SharePoint stage environment before enabling it in production envionment. In fact, we follow this process all the time to be on safe side :-)

    Alright, so we will talk about incoming e-mail feature and e-mail enabled lists and libraries in SharePoint 2007 today.

    Before I start, let me tell you that we do NOT have MS Exchange server setup in our organization for e-mail routing but we have unix based mail routing system called - Majordomo. So it may differ from configuring incoming e-mail feature in MOSS 2007 with Microsoft recommended mail routing system- MS Exchange.

    As you all know we can enable incoming e-mail in MOSS 2007 by going to Central Administration > Operations > Incoming E-Mail Settings. Here is how we have configured it,

    1. Enable sites on this server to receive e-mail? Yes

    2. Settings mode: Automatic

    3. Use the SharePoint Directory Management Service to create distribution groups and contacts? Yes

    Note: This setting is required ONLY if you want contacts to be created in your organization's user directory allowing people to find e-mail enabled SharePoint lists in their address book. This service also provides support for the creation and management of e-mail distribution groups from SharePoint sites. If you don't want contacts to be created in your organization's user directory you can choose "No". Incoming e-mail feature will work regardless of what you select for this option.

    If you have selected "Yes", you need to provide additional information. If you are not sure of this information, please contact the person who manages Active Directory and domain services for your organization. For example, we have

    4. Active Directory container where new distribution groups and contacts will be created: OU=SPOU, OU=Organization, OU=ControlledObjects, DC=hq, DC=MyDomainName, DC=com

    Note: I have changed few settings to keep the privacy.

    5. SMTP mail server for incoming mail: MOSSServer1.hq.MyDomainName.com

    6. Accept messages from authenticated users only? Yes (We have enabled incoming e-mail feature for intranet use only however we don't want any spam e-mails in our system when we enable it for external accounts so it is always safe to select "Yes" option here.

    7. Allow creation of distribution groups from SharePoint sites? Yes

    8. Distribution group request approval settings: Create new distribution group and Delete distribution group are selected.

    9. E-mail server display address: sharepoint.hq.MyDomainName.com

    Note: This option is little tricky to provide a custom address here. Please note that the SMTP server name for incoming mail is "MOSSServer1" however we want contacts for e-mail enabled lists and libraries with suffix "@sharepoint.hq.MyDomainName.com". We can do this by adding another domain alias in IIS for SMTP Virtual Server. Here are the steps to add the domain alias for SMTP Virtual Server,

    (i) Open IIS, where you have SMTP Virtual Server installed.
    (ii) Expand Default SMTP Virtual Server.
    (iii) Right click on Domains and select New => Domain.
    (iv) Select Alias.
    (v) Provide Name (Another Alias of this SMTP Virtual Server e.g. we have used sharepoint.hq.MyDomainName.com and click Finish button.

    Note: MS Exchange or your mail distribution system (Majordomo in our case) must be configured to route all emails that suffix with @sharepoint.hq.MyDomainName.com to C:\Inetpub\mailroot\Drop folder of SMTP Virtual Server installed on MOSSServer1.

    10. Safe E-Mail Servers: Accept mail from all e-mail servers is selected.

    That's it, incoming e-mail feature for MOSS 2007 is configured...Congratulations!

    Now, Let's talk about testing this feature...(Please keep in mind that we have Unix based Majordomo mail distribution system in our organization) Most of the time it worked fine for receiving e-mails in SharePoint however we stopped receiving e-mails after 2-3 days of testing. We were unable to telnet into server on port 25. SharePoint server(with Virutal SMTP Server installed) was not listening on port 25. We checked “Connection” property under “Access” tab of SMTP Virtual Server properties and noticed that SMTP server is accepting connection only from 196.X.X.123 server however we configured to receive e-mails from any e-mail server. So We removed that IP Address (196.X.X.123) from the “Computers” tab and set connection settings to “All except the list below” by keeping “Computers” tab empty. After this change, we started receiving e-mails in SharePoint as normal but question was how this change was occurred and who made changes to “Connection” settings? and here is the answer :-)

    While testing incoming e-mail feature in SharePoint, we set “Accept mails from these safe e-mail servers” with the above IP Address (196.X.X.123) and that changed “Connection” settings of SMTP Virtual Server in IIS. This was the root cause of this issue. So be very careful when you make any configuration changes to your incoming e-mail settings.

    As I mentioned before I am pretty excited about announcing this feature in our SharePoint production enviornment however here are the few things what I am concerned about,

    How can we manage undelivered emails?

    1. What happens to emails, which are sent to wrong email addresses? SharePoint logs refer that as Unknown Alias. How does SMTP server handles it? Is there anyway we(or SharePoint Admin email account) can get notified for undelivered email messages? We tried to set email account in SMTP server properties for Undelivered emails but that didn't help. We would like sender to receive bounce back email when email is sent to wrong email address or at least SharePoint administrator account get notified when email is not delivered to SharePoint.

    2. We have Distribution List set for different groups. Let's say for example, dl-spadmins has all email accounts of SharePoint administrators. If we add email address for SharePoint document library in this DL and then send email to dl-spadmins, all members of that DL receive email but SharePoint document library does NOT receive this email. Is there anyway to troubleshoot this issue?

    Why we want to add email address for SharePoint document library to Distribution List (DL)? Because we can not find those contacts in SharePoint even though we have configured Directory Management Service for incoming email feature in SharePoint and that is because we have Majordomo mail distribution system instead of MS Exchange (I believe this is the reason, we can not find those contacts in MS Outlook but I am not sure) So if we add contacts for important SharePoint document libraries to DL of relevant department (Site Collection), anybody can send email to DL, which will send email/document to all the members of DL as well as SharePoint document library and nobody needs to remember email address of SharePoint document library. All they need to do is, just send an email to DL and it will reach both the members of DL and SharePoint document library, which these members are going to access later.

    When you add email address of email enabled Document Library to Distribution List(DL), permissions for email must be set to "Accept e-mail messages from any sender" in order to receive email in SharePoint and yes, It shows "System Account" for those messages or the documents received in Document Library. This is already been discussed in this Blog and unfortunately we are still struggling for an appropriate solution. If you set "Save all attachments in folders grouped by e-mail sender" , it creates a new folder for each new sender and then add attachments to that folder however it still shows "System Account" under "Modified By" field but at least it gives you an idea (by looking at the folder name) who sent that email/documents to your Document Library.

    If you set "Accept e-mail messages based on document library permissions" then the email will not be received in SharePoint.

    One more thing...

    If you set "Accept e-mail messages based on document library permissions" option for your Document Library and if somebody, who doesn't have permissions on your Document Library sends an email to your Document Library, it never arrives in your Document Library. Also Sender will not receive any bounce back. So Sender assumes that he has successfully sent an email to your Document Library and you never receive it. Now, this issue might be specific to Majordomo(Unix based) email distribution system and may work well with MS Exchange configuration. I have tested this in my Lab with MS Exchange and I believe it sends the bounce back message if you don't have permissions on the Document Library but I am not 100% sure. :-(

    Finally here is the matrix for reusing same contact name for same library or different library in SharePoint,

    Reuse_Contact_in_Email_Enabled_Lists_and_Libraries

    References:
    http://www.combined-knowledge.com/Downloads%202007.htm
    http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=31

    May 07

    How to install Office 2003 web parts in MOSS 2007?

    Back in September 2007, we upgraded SharePoint Portal Server 2003(SPS 2003) to Microsoft Office SharePoint Server 2007 (MOSS 2007). For some unknown reasons, after finalizing upgrade to MOSS 2007, We have MOSS 2007 environment depending on configuration database of SPS 2003. We are unable to create a new site collection/site if we detach old SPS 2003 configuration database.

    One of the best possible way to fix this issue is to reconfigure existing SharePoint 2007 environment and get rid of both old SPS 2003 configuration database and old MOSS 2007 configuration database, which was created as a part of migration to MOSS 2007. We can also think of creating a new web application (Portal Site) and move content databases from original web application to a new web application however we did not want to take any risk of inviting new issues without thoroughly testing it in our MOSS 2007 stage environment, which is almost identical to our MOSS 2007 production environment. I will talk about these two approaches for fixing old (SPS 2003) configuration database dependency issue some other day but my intension of mentioning this issue is to talk about how to make Office 2003 web parts and components to work if in case you upgrade or reconfigure your MOSS 2007 environment.

    As I mentioned before, the best possible way to resolve SPS 2003 configuration database depedency issue in MOSS 2007 is to reconfigure MOSS 2007 and that is what we tried first in our MOSS 2007 stage environment. SharePoint stage environment was upgraded to MOSS 2007 the same way as production environment and stage environment also has SPS 2003 configuration database dependency issue. So we reconfigured SharePoint stage environment successfully (I will talk about it in detail some other day) and we noticed that we were unable to install Office 2003 web parts and components after this. We are still using MS Office 2003 company wide. So the only option, we were left with was to reinstall Office 2003 web parts without installing WSS 2.0/SPS 2003. We tried to install Office 2003 web parts and we received following error:

    "You must install Windows SharePoint Services 2.0 before you install Office 2003 Web Parts and Components."

    We found following KB Articles, which explain more about this error message and its work around.

    http://support.microsoft.com/kb/929320
    http://support.microsoft.com/kb/927602
    Here is the link for downloading Office 2003 Add-in for MOSS 2007,

    http://www.microsoft.com/downloads/details.aspx?familyid=38be67a5-2056-46a1-84b1-337ffb549c5c&displaylang=en

    So if you upgrade SPS 2003 to MOSS 2007 or if you reconfigure existing MOSS 2007 environment and if you want to reinstall Office 2003 web parts (to use it with MS Office 2003, I know nobody would personally prefer it over MS Office 2007 but if your company is still using MS Office 2003 with MOSS 2007), you can download and install Office 2003 Add-in from above link, which will allow you to use Office 2003 web parts in MOSS 2007.

    Thanks to Microsoft for releasing this Add-in on time otherwise we would require to start from the scratch, meaning refresh OS on the servers, install SPS 2003 and then upgrade it back to MOSS 2007 just to have Office 2003 web parts working in MOSS 2007.

    April 17

    Custom code to get the list of site collection administrators for all the site collections in SharePoint server farm

    Alright we have changed our idea of giving "Administrator" level access to all the site collections to the outsourced team. Instead we decided to deliver them an Excel document with the URL and site collection administrators for each site collection. In fact, all the outsourced team members have access to their own team site. So we are going to upload this Excel document to their team site.

    As usual, I wrote C# console application to achieve this.

    Note:

    1. This code assumes that you have all the site collections created under "sites/"
    2. This is a console application so you have to use it the way you use stsadm command.
    3. This code will output a text file with comma separated values when you run it as follows,

    SCAdmin.exe -url http://sharepoint.domain.com > SCAdmins.txt

    4. Finally you can import SCAdmin.txt file to an Excel document with ","(comma) selected as separator for creating a new column.

    5. SCAdmin.txt file should look like this,

    http://sharepoint.domain.com/sites/SC1, domain\spadmin;
    http://sharepoint.domain.com/sites/SC1, domain\spadmin; domain\user2; domain\user3
    http://sharepoint.domain.com/sites/SC1, domain\user4; domain\user5;
    http://sharepoint.domain.com/sites/SC1, domain\spadmin; domain\user6
    http://sharepoint.domain.com/sites/SC1, domain\user7;
    ...............................
    ...................
    ........

    6. When you import SCAdmin.txt to an Excel document by selecting "," (comma) as the separator, it will place URL in first column and site collection administrators in second column.

    Disclaimer: Please test this code in test environment before you use it. I will not be responsible the outcome of this code.

    Here is the code,

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Administration;
    using Microsoft.SharePoint.StsAdmin;

    namespace SCAdmins
    {
        class SCAdminsClass
        {
            static void Main(string[] args)
            {
                SCAdminsClass sc = new SCAdminsClass();
                sc.getSiteCollectionAdministrators(args);
            }

            private void getSiteCollectionAdministrators(string[] args)
            {
                try
                {
                    string mode = "";
                    string virtualserver = "";

                    // get command line arguments
                    if ((args.Length == 0) || (args.Length == 1 && (args[0] == "-?" || args[0] == "-help")))
                    {
                        displayOutput("", mode);
                        displayOutput("SCAdmin.exe -url VirtualServerURL [-quiet]", mode);
                        displayOutput("", mode);
                        displayOutput("  -url VirtualServerURL: Full URL of virtual server starting with http://", mode);
                        return;
                    }

                    // loop through command line arguments
                    for (int i = 0; i < args.Length; i++)
                    {
                        if (args[i] == "-url")
                        {
                            virtualserver = args[i + 1];
                            i++;
                            // make sure url parameter starts with http:
                            if (!virtualserver.StartsWith("http:"))
                            {
                                throw new ArgumentOutOfRangeException("url parameter should start with http://");
                            }
                        }
                        else if (args[i] == "-quiet")
                        {
                            mode = "quiet";
                            continue;
                        }
                        else
                        {
                            displayOutput(String.Format("Unrecognized switch {0}", args[i]), mode);
                            return;
                        }
                    }

                    // connect to web application on virtualserver
                    SPWebApplication webApp = SPWebApplication.Lookup(new Uri(virtualserver));
                    // create site collections object for web application
                    SPSiteCollection siteCollections = webApp.Sites;

                    string SCUrl = "";
                    int SCCount = 0;
                    SPSite site = null;
                    SPWeb web = null;
                    string admins = "";
                    // loop through site collections
                    foreach (SPSite siteCollection in siteCollections)
                    {
                        site = new SPSite(siteCollection.Url);
                        web = site.OpenWeb();
                        SCUrl = siteCollection.Url;
                        if (SCUrl.Contains("sites"))
                        {
                            SCCount++;
                            SPUserCollection users = web.Users;
                            foreach (SPUser user in users)
                            {
                                if (user.IsSiteAdmin)
                                {
                                    admins = admins+user.LoginName+"; ";
                                }
                            }
                            Console.WriteLine(SCUrl + ", " + admins);
                        }
                        admins = "";
                    }
                    //Console.WriteLine("Total Site Collection: " + SCCount);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            private void displayOutput(string text, string mode)
            {
                if (mode != "quiet")
                {
                    Console.WriteLine(text);
                }
            }
        }
    }


    Please send me an email if you need a zip file for this C# project. Enjoy!


    April 16

    How to add another site collection administrator to all the site collections in SharePoint server farm?

    First of all, let me make this clear that I am not a good SharePoint Developer but I have tried my best to achieve this programmatically.

    Few days back, we decided to outsource SharePoint support. The new support professionals will be responsible for troubleshooting basic SharePoint issues and if require, they should be able to provide the end user with the contact information of particular site collection administrator.

    Basic SharePoint issues such as - Request for creating a new sub site under particular site collection(Top Level Site or Departmental Site), Unable to access SharePoint, Unable to edit SharePoint contents, Unable to access lists, libraries etc.

    We have site collection created for each department and each site collection has one or more site collection administrators, who are responsible for managing the site collection, they belong to. If site collection administrators are unable to address the end user's issue, the request will be forwarded to SharePoint Farm Administrators - I am the part of that team.

    Now as we decided to outsource SharePoint support, we had following requirements:

    1. Create a new AD account, which will be used by all the support professionals to access any site with "Administrator" privileges in the SharePoint server farm. Lets say this account is "domain\spsupport"
    2. If any support professional is unable to resolve the issue and he/she wants to direct end user's request to the site collection administrator, he/she should be able to access any site collection with "Administrator" privileges to provide name and contact information of site collection administrator to the end user. Support professional should use "domain\spsupport" account for this purpose. They can also use this account to find out the content owner information and forward permissions requests/issues to the content owner - e.g. If somebody needs access to a specific document library of a site or when somebody request specific permissions to lists/libraries of a site.
    3. Finally make "domain\spsupport" account as site collection administrator for all the site collections in the SharePoint server farm.

    We have almost 300 site collections and adding "domain\spsupport" account as site collection administrator to each site collection using Central Administration site or Site Settings does not seem to be an appropriate solution. So I decided to write a simple C# application which will output stsadm commands for adding "domain\spsupport" account as site collection administrator to each site collection in the farm.



    Here is the code,

    Note:

    1. This code assumes that you have all the site collections created under "sites/"
    2. This is a console application so you have to use it the way you use stsadm command.
    3. This code will output stsadm commands. You may run it as follows to generate batch file for all the stsadm commands,

    AddSCAdmin.exe -url http://sharepoint.domain.com -user domain\spsupport > addSCAdmin.bat

    4. Finally you can run addSCAdmin.bat file, which will execute all the stsadm commands for adding domain\spsupport account as site collection administrator.

    5. addSCAdmin.bat file should look like this,

    stsadm -o siteowner -url http://sharepoint.domain.com/sites/SC1 -secondarylogin domain\spsupport
    stsadm -o siteowner -url http://sharepoint.domain.com/sites/SC2 -secondarylogin domain\spsupport
    stsadm -o siteowner -url http://sharepoint.domain.com/sites/SC3 -secondarylogin domain\spsupport
    stsadm -o siteowner -url http://sharepoint.domain.com/sites/ITSiteCollection -secondarylogin domain\spsupport
    stsadm -o siteowner -url http://sharepoint.domain.com/sites/MktSC -secondarylogin domain\spsupport
    ...............................
    ...................
    ........


    Disclaimer: Please do not use this code unless you have tested it in test environment first. I will not be responsible for the outcome of this code.

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Administration;
    using Microsoft.SharePoint.StsAdmin;

    namespace AddSCAdmin
    {
        class AddSCAdminClass
        {              
            static void Main(string[] args)
            {
                AddSCAdminClass sc = new AddSCAdminClass();
                sc.addSiteCollectionAdmin(args);
            }

            private void addSiteCollectionAdmin(string[] args)
            {
                try
                {
                    string mode = "";
                    string virtualserver = "";
                    string user = "";

                    // get command line arguments
                    if ((args.Length == 0) || (args.Length == 1 && (args[0] == "-?" || args[0] == "-help")))
                    {
                        displayOutput("", mode);
                        displayOutput("AddSCAdmin.exe -url VirtualServerURL -user domainuser [-quiet]", mode);
                        displayOutput("", mode);
                        displayOutput("  -url VirtualServerURL: Full URL of virtual server starting with http://", mode);
                        return;
                    }

                    // loop through command line arguments
                    for (int i = 0; i < args.Length; i++)
                    {
                        if (args[i] == "-url")
                        {
                            virtualserver = args[i+1];
                            i++;
                            // make sure url parameter starts with http:
                            if (!virtualserver.StartsWith("http:"))
                            {
                                throw new ArgumentOutOfRangeException("url parameter should start with http://");
                            }
                        }
                        else if (args[i] == "-user")
                        {
                            user = args[i + 1];
                            i++;
                        }
                          
                        else if (args[i] == "-quiet")
                        {
                            mode = "quiet";
                            continue;
                        }
                        else
                        {
                            displayOutput(String.Format("Unrecognized switch {0}", args[i]),mode);
                            return;
                        }
                    }

                    // connect to web application on virtualserver
                    SPWebApplication webApp = SPWebApplication.Lookup(new Uri(virtualserver));
                    // create site collections object for web application
                    SPSiteCollection siteCollections = webApp.Sites;

                    string SCUrl = "";
                    int SCCount = 0;
                    // loop through site collections
                    foreach (SPSite siteCollection in siteCollections)
                    {
                        //site = new SPSite(siteCollection.Url);
                        SCUrl = siteCollection.Url;
                        if (SCUrl.Contains("sites"))
                        {
                            SCCount++;
                            Console.WriteLine("stsadm -o siteowner -url " + siteCollection.Url +" -secondarylogin "+user);
                        }
                    }
                    //Console.WriteLine("Total Site Collection: " + SCCount);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            private void displayOutput(string text, string mode)
            {
                if (mode != "quiet")
                {
                    Console.WriteLine(text);
                }
            }
        }
    }


    I have created C# project for this solution. Please send me an email if you want the zip file for the whole project.

    I hope this will help few people for such specific need.




    April 15

    April 2008

    How to calculate age of list items in SharePoint:

    Here are the steps to calculate age of the list items in SharePoint,
     
    1. Go to the list where you want to calculate age of the items e.g. Task List
    2. Click Settings => List Settings and create a new column and name it e.g. "Today", There is no need to select any specific type for this column (Just type the name of the column and click "OK" at the bottom)
    3. Create one more column and name it e.g. "Age in Days". Select "Calculated(calculation based on other columns)" type and provide formula using "Today" column which you created in step 2 e.g. I have entered
    =[Today]-[Created]. Select "number" for the data type and 0(zero) in "Number of Decimal places". So basically it will calculate difference between today's date and date the item was created.
    4. After 3rd step, remove "Today" column, which you have created in step 2. When you remove Today column, SharePoint automatically refers "Today" (which has been deleted now) as the today's date in the formula calculation.
    5. Go back to Task List and it should display the number of days under the "Age in Days" column of each items in Task List.