Showing posts with label Sharepoint. Show all posts
Showing posts with label Sharepoint. Show all posts

Wednesday, April 8, 2015

Hide menu items in a SharePoint site

An interesting question today on technet forum on how we can avoid display of site contents menu in a SharePoint site for users with just read permissions.



My initial reaction was to use security trimming around this control but then there are more options targeted specifically to menu item controls.

So here are the steps

1. Open up the default master page in SharePoint designer. (How to identify default master page is a very dirty tweak but does work).

2. Navigate to the section where SharePoint:MenuItemTemplate are available (right after wssuc:Welcome control usually)

you will find this:





3. The permissingstrings property is the key - choose the permission string for which you want to enable this menu. I changed it to Add and edit list items permissions

  <SharePoint:MenuItemTemplate runat="server" id="MenuItem_ViewAllSiteContents"
 Text="<%$Resources:wss,quiklnch_allcontent_15%>"
 Description="<%$Resources:wss,siteactions_allcontentdescription%>"
 ImageUrl="/_layouts/15/images/allcontent32.png?rev=23"
 MenuGroupId="200"
 Sequence="240"
 UseShortId="true"
 ClientOnClickNavigateUrl="~siteLayouts/viewlsts.aspx"
 PermissionsString="AddListItems, EditListItems"
 PermissionMode="Any" />


4. Save the master page and reload the site collection


Now to have a good idea of all permissionstrings  that are possible, see this entry

Friday, December 31, 2010

FileNotFound Exception while creating SPSite Object

The file not found exception could be one of the first SP 2010 exception any developer could face. For one it is surely something we did not encounter in 2007.

The usual suspects are well documented in many blogs:
http://edwin.vriethoff.net/2010/03/22/visual-studio-and-sharepoint-2010-new-spweb-returns-filenotfoundexception/

they are related to
1. project not compiled against .net 3.5
2. platform target not x64 or any

another 1 to look for is debug platform target is not x64. Check this in Project --> Properties --> Debug tab
If you have trouble setting this use the configuration manager, you can invoke the dialog from the debug drop down you see in tool bar.

I am not elaborating these much because that is not the point of this blog, I could find the above three solutions well documented else where

If your simple new SPSite (url) does not still work (mine dint) then start fiddling around for some clues at the usual places - eventvwr logs, 14 hive logs etc.,
what I found in eventvwr application logs is this


SQL database login for 'SharePoint_Config' on instance 'axxxxxxx' failed. Additional error information from SQL Server is included below.


Login failed for user 'xxxx\yyyyyy'.


That's it, this very informative error message can be thrown even if the user account under whose content ur code is running (logged in user if it is a console app) does not have login rights - and probably read access as well..
Go ahead and provide the necessary permissions - if u had broken ur head for 3 hrs to get around to this point, you would most likely end up giving sysadmin priv to the user and get past this error like i did, but pbly read on config and the content db shd be enough.

Tuesday, August 31, 2010

SharePoint 2010 Management Shell: Finding your way around

Windows powershell is new to SharePoint 2010 developers/administrators. In terms of technology and adoption, however, it is the other way around - Powershell has been around for long. Exchange Server, SQL Server have their own management shell on top of PS. 


SharePoint, as is the practice, understandably, takes a while to adopt and use the latest; the Sharepoint snapin and cmdlets comes with the 2010 release. 


It should ideally be bye-bye time to stsadm command now. If not it is a good excuse to create your own custom cmdlet


For new users, it will take a while to get an idea of the power of Powershell; here are a set of tips for finding your way around and getting comfortable with using it


A couple of useful commands that comes in handy everytime for me are get-command and get-help.


Note: if you donot find SP after the hyphen then the cmdlet is not a SharePoint cmdlet and most probably it is available as cmdlet in Windows Poweshell

Let us take the scenario where you have created a farm solution (not sandbox, with 2010 we have to be clearer :)) and is planning to add that to your environment. Do not use stsadm -o addsolution however tempting it turns out to be - look for the corresponding powershell cmdlet


Tip #1: Use Get-Command with wildcards:
You know for sure that cmdlet name will solution, so search for it in SharePoint management shell with
Get-Command *solution*






Tip #2: Use Get-Command with specific command
Now that you have go the cmdlet look closer at to what is its syntax
Get-Command Add-SPSolution 








Tip #3: Use Get-Help with specific command



Get Help is another command you can use, which will say in words and through description (surprisingly good documentation) what the command is all about
Get-Help Add-SPSolution







Tip #4: Use Get-Help with examples switch



In case you need to see some examples on how the command has to be used go for examples switch. 
Get-Help Add-SPSolution -examples



Finally, go ahead and add the solution

You would like the output it gives, right :) Now try to find out how to deploy the solution through cmdlet. Don't be surprised by the output that cmdlet gives (:()



Note: good time to familiarize yourself with the term switch. In powershell there are 3 terminologies used for specifying the inputs to a cmdlet
Parameter : parameter is the name of the cmdlet property for which a value is provided (for e.g. in the Add-SPSolution cmdlet call LiteralPath is a parameter)
Argument : The value that is passed to the parameter (for e.g. in the Add-SPSolution cmdlet call the physical path of the wsp file is the argument)
Switch : the parameter that does not need an argument (for e.g. in the Get-Help cmdlet examples is a switch, imagine turning on a switch and a behavior gets added to the cmdlet)

Friday, August 27, 2010

c#3.0 enhancements for SharePoint developers

SharePoint 2010 adds the capability of LINQ, we would probably use this more for queries than CAML. Additionally, if we are dishing out client object model code, LINQ queries and lambda expressions (=>) are good to know. Now they have been in existence for a couple of years but we, the flock of SP coders, have always been slow adopter of new language and framework features; time to get used to them.

Before getting on with LINQ having an understanding of C# 3.0 language enhancement (=> included) is important.

Here is a piece of code that gives an example of each of these enhancements


namespace CHash3Enhancements
{
    class Person
    {
        public int Age { get; set; }
        public string Name{ get; set; }


    }
    
    static class Enhancements // static required for method extensions
    {
        // static method extensions
        static int GetAgeAfter5Years(this Person o) // note the this keyword in args here
        {
            var ageAfter5 = o.Age + 5;
            return ageAfter5;
        }


        static double GetAveragePositiveValue(this IEnumerable<int> o) // note the this keyword here
        {
            var avg = o.Where(a => a >= 0).Sum() / o.Count(a => a >= 0); ;
            return avg;
        }




        static void Main(string[] args)
        {
            // implicitly typed variables
            var i = 1;
            var str = "abc";
            // collection and method initialization
            var person = new Person() { Age = 20, Name = "partha" };
            var persons = new Person[] { new Person { Age = 20, Name = "ab" }, new Person { Age = 20, Name = "sv" } };
            var intarr = new int[] { -5, 4, 1, 2, 3 };
            // lambda expressions
            var lt3arr = intarr.TakeWhile(a => a < 3);
            Console.WriteLine(lt3arr.Count(a => a>1));


            // static method extensions
            Console.WriteLine("Avg Positive: {0}", intarr.GetAveragePositiveValue());
            Console.WriteLine("Age after 5: {0}", person.GetAgeAfter5Years());


            // anonymous types
            var anonymousperson = new { Age = 12, Name = "jack", addProp = "look" };
            Console.WriteLine("that anon vals are {0} and {1}", anonymousperson.Age, anonymousperson.addProp);


            Console.WriteLine("the implicity defined values are {0} and {1}", intarr[2], str);
            Console.WriteLine("the initialized values are {0} and {1}", persons[0].Age, persons[1].Name);
            Console.Read();
        }
    }
}


 An important understanding to have here is this: None of the enhancements shown above are framework enhancements, the .net framework has not changed a bit; these are only  language and compiler enhancements

Friday, October 10, 2008

MOSS Licensing

The below understanding is based on the FAQs on http://office.microsoft.com/en-us/sharepointserver/HA101655351033.aspx and also based on the contents at http://office.microsoft.com/en-us/sharepointserver/FX100492001033.aspx

 

If you are going for MOSS we would need

 

Product

Price

Office Sharepoint Sever 2007

$4424

 * Prices may depend on how much MS charges locally.

Ø       There are no options here, you would need to purchase this license and install it on each of the server that needs to have MOSS.

Ø       If you are going for VMs then each VM instance (even if it is on a single server) would need the above license

Ø       Thankfully, there is no process based licensing so it does not matter how many CPUs are present on the server on which Office Sharepoint Server 2007 is installed

 

Additionally, for clients to access the server à we need CALs

 

We can take Standard CALs in which case we won’t have access to some of the business intelligence capabilities and business process capabilities (particularly, browser based forms services).

For a complete capability we need to have enterprise CAL in addition to the standard CAL for each CAL we take

 

Product

Price

Standard CAL

$94

Enterprise CAL

$75

 

So Total $s we would need to shell out will depend on the number of employees who would need access to the sharepoint server

A short detour here to clear the types of CALs 


Client Access Licenses

 

Ø       There are multiple CALs, prominent among them are Device CALs and User CALs

 

Ø       Device CALs are for each computer that would access the client. If multiple users are going to use the same machine (in case of companies where people work in shifts) then this license would make sense

 

Ø       If each user has one device atleast and each user should be able to access the server from multiple devices then we should go for User CALs.

 

we are back... 

Assuming 1000 users you would need = 4424 + 169*1000 = $ 1,73,424


(if you are wondering how it is 169 * X --> for enterprise license you need to purchase standard also :) )

 

That is a lot of money

 

Instead, you can probably go for Sharepoint Server 2007 for internet sites which can be used for creating extranet sites that both employees and external users shall user

 

Product

Price

Office Sharepoint Sever 2007 for internet sites

$40,943

 

The server license might look 9x of just the server license but you don’t need CALs and that would make a lot of difference

 

It looks like MOSS for internet sites is a better option if there are more that 216 users in the organization. 

But WAIT, you just can’t do that – or rather you can but you should not do that. As per licensing terms the MOSS for internet sites license should not be used to create and manage contents that is only for internal users.

 

Refer http://www.microsoft.com/licensing/resources/glossary.mspx for de-mystifying the licensing terms of MS to some extent

Tuesday, October 7, 2008

Travel Survival Kit for your Sharepoint workflow journey

Make sure you have the following installed in your machine before you design your first all important sharepoint workflow with visual studio 


Bon voyage!!!

Sunday, October 5, 2008

Sequential Vs State Machine workflows

In short the ability to “go back” during the flow is what differentiates state machine workflow from the sequential

If you dig deeper look at the attribute of a state machine flow
1. The sequence is not predetermined - The entity can go from one state to any other state based on external events
2. An event can result in no state transition also
3. Who controls the flow  the user or the workflow itself. If user can make a set of choices that can lead the entity to different states then it is the user who controls the flow.

Sequential workflow can also have branches and loops but they are less complex and well laid out.

If the question is can’t I just use sequential everywhere if I am smart enough to handle  yes you can, probably you will succeed also but the ROI is poor. To quote Dave

“The Sequential workflow, of its nature, encodes all the possible sequences of behavior in its structure. But here [State machine], we don’t care. We only need to know about the current state, and what can be done next. So if we spend time modeling routes through the process, event though we don’t in fact care about them, and these routes are many, as they are in the bug problem, then the Return On Investment from the Sequential style inevitably becomes very poor.”

http://blogs.msdn.com/davegreen/default.aspx

It looks like we will use state machine most often than sequential considering that most business cases are reasonably complex.

Friday, October 3, 2008

After weeks of "it is just around the corner" compromises, i finally managed to create time for myself to reread the book from the start.. last time i had to stop myself half way.. coz of various reasons which i conveniently choose not to remind myself again.. now on to the book, an excellent introduction by the authors..

Why do we need such a piece of software --> every orgnaization creates 100s if not thousands of sites for themselves for marketing, internal employee and policy mgmt and what not.. going through the same grind of creating html/script based pages, accessing db through or by passing a middle tier.. designing the db etc., are definitively non productive. As the grind is a well laid out sequence of steps and not any magic, there is bound to be an automatic page creator and content manager sw and you can imagine Sharepoint to be one such.

Now a non technical person in your organization (read it as your HR Director/manager or CFO or accounts manager or your office security) can create pages and content that anyway you will not use or by all means will not be useful!!

So is it death knell for the web site developer? Not quite.. just like BPM is and turned out to be (u can create processes linking pieces of services but these services will have to be developed and made by linkable by us) here u can create pages and basic contents but you will neverthe less need our skills to customize the pages - which most often would be required.

What more can we do?

i should not be writing this post.. coz i have never worked on sps2003, so anything we can do with Sharepoint 2007 is more than whatever i have done before. For academic sake.. it might help to know these

  • you can bind events to lists also and more importantly synchronous events --> which means you can invalidate an action done on the list (like delete of an item)
  • you can assign work flows 
  • asp.net forms authentication (for ur extranet clients) 
  • lists and list item versioning and indexing 

too academic perhaps, let me stop here..  it is not all that useful to know that whatever is done with 2007 is something u cud not have done with 2003.. what use is it anyway? you are not evaluating the option of purchasing 2003 instead of 2007, r u?
As every book, every evangelist would say about the current version of the product (until beta of the next version is out) MOSS 2007 is unlike anything anyone has seen before or after. It is built on .net FXs 2 and 3.5, the later for WWF&WCF I presuppose and ASP.Net 2.0.

Some of the interesting points to note

  • it uses HTTPHandlers for directing to WSS code from ASP.net code rather than directly rerouting from IIS using ISAPI filters... so what? one may ask and the reply (which i am going to demand from every asp.net guru i am going to interview, hence forth) is that the asp.net context would be set and be available for http handlers  - READ THIS AGAIN
  • uses the master page feature of asp.net 2.0 
  • customized pages (unghosted) are stored in sql server and rendered using asp.net 2.0 virtual path feature, i.e, no more are we bound to have a physical file to be compiled and converted in to html in asp.net 2.0 and SPS leverages that
that is all worth while to list in the definitive guide.. i remember reading more in inside wss.. so this post would most definitively have an update

Reading the definitive guide

Chanced upon this book in my machine while i was looking for inside wss.. definitely seems to be a definitive guide.
some excerpts..
you (as in ur organization) would most definitively need MOSS if 
a. you have geographically distribution teams which need to collaborate
b. there is an impending or atleast an expected document or content explosion which needs to be averted 
 
now, that puts MOSS next to roti kapda aur makaan in terms of necessity

Sites vs Site Collections

Now this is a question i do not fail to ask anyone who appears for a sharepoint interview... 
Now, Mr/Miss ____ I am impressed to hear what you have done with sharepoint; Tell me this, a client, say the HR department asks you to create a few sharepoint pages for them.. they have certain specific information to be displayed under HR India, HR China etc., for each country and they also have common content for HR department itself - Will you create a HR Site and subsites or will you create a HR Sitecollection? How would you justify it and what is the real difference between the two?
 
I would accept both the answers, but i generally look for is the reasoning the candidate gives for either of the solution
 
Here is what i would love to hear:

Every webapplication has one content db of its own and the wss deployment has a common configuration db to store all config information of all web apps in the farm.. (why do we need this information here? :) just because i do not want to create a new post just to write this small but very important information )
 
Now back to sites.. consider a site as a big box.. which can have contents like list, doc libs etc. and also content displayers called pages.. it is like this - if you open the box, you will see different pages which can show a different perspective of what the box contains. 

Now these boxes can contain other boxes inside them which can have contents, pages and more boxes inside them and so on. Each of this box inside another box is called a subsite..

What more, we can lock these boxes and the data within the boxes and provide keys to specific individuals to access the contents and pages.. this is authorization

Additionally, we can color the boxes and the display the pages, paste stickers brand them as and how we want.. this is called setting a theme..
 
All this is great,, but where do these boxes reside.. as i told they can reside in another box.. but where does the top most box reside --> inside a logical entity called site collection.. though it is called a site colleciton it has only one top level site which can have any number of site under it and further down (ie why  it is a collection)
 
Now would you give your HR department a site or a site colleciton.. 
By creating a site collection, i can just assign my HR Director and recruitment manager as site collection administrator and wash my hands off with respect to handling the administrative burden to my HR director (do you think they can pull it off.. :) )
I can of course create site collection specific groups and assign certain permissions which they can use to authorize their sites and contents
I can also create some content types and columns that they can use in their lists and which is common for all items
Further, i can set up backup, restore copy etc., for their site collection specifically !! 

Once we have an idea of these concepts we can pick an option based mainly on how independently the content needs to be managed.

pick your pick..