Monday, November 5, 2012

How To: Lock Down Social Features in SharePoint 2010



After having provided these instructions to a few clients as part of broader SharePoint projects/strategies I thought I could share a short how to article that outlines everything you should need to know for locking down or deactivating SharePoint’s social features effectively. Hopefully after you lock them down you will roll them out in time so that your organization can realize the business benefit they provide in a more controlled/planned manner.
What follows are the tasks that could be executed after a SharePoint environment has been provisioned and validated. These tasks are specifically designed to remove, hide, or disable many of the social features from SharePoint 2010. Effectively if you follow all of these features you will have a ‘non socially enabled’ SharePoint 2010 implementation.
Adjust User Profile Service Application Permissions
What follows are the steps that will be executed in order to ensure that certain social features are not available to users until the organization is ready to roll them out.
  1. Go to Central Administration > Application Management > Manage service applications > User profile service application
  2. From the ribbon, Click “Manage User Permissions” under People
  3. In the “Permissions for User Profile Service Application” pop up, select a user group, e.g. All authenticated Users.
  4. Uncheck the Create Personal Site and Use Social Features checkboxes.
  5. Click OK.
De-activate Farm Level Feature: Social Tags and Note Board Ribbon Controls
In order to ensure that Social Tags and Note Board Ribbon Controls are not available to users we will disable this farm level feature.
  1. Go to Central Administration > System Settings > Manage farm features
  2. De-activate Social Tags and Note Board Ribbon Controls.
Update MySite Host Navigation
Additional steps must be taken to remove the default links to different sections of a person’s profile page. To reset these settings it will be necessary to re-create these links.
  1. Navigate to the MySite Host root Site Settings page.
  2. Select Quick Launch
  3. Remove The Following Links:
    1. Description: “Content” & URL: “/personcontent.aspx”
    2. Description: “Tags and Notes” & URL: “/_layouts/thoughts.aspx”
    3. Description: “Colleagues” & URL: “/_layouts/MyContactLinks.aspx”
    4. Description: “Memberships” & URL: “/_layouts/MyMemberships.aspx”
    5. Optional: Any additional Libraries/Lists references.
Authors Note: Remember that by default the MySites have no way back to your Intranet or Portal. Make sure you have updated the MasterPage or navigation settings as needed to allow users to seamlessly move from the MySites/Profile pages to other key SharePoint systems.
Modify User Profile Properties
There are specific user profile properties that will be adjusted from SharePoint’s default settings.
  1. Go to Central Administration > Application Management > Manage service applications > User profile service application
  2. Select Manage User Properties
    1. Update Properties According To Excel Sheet
    2. The Excel Sheet will highlight ‘changes’ in red. So when planning profile properties identify the changes you want/need and then keep a record of the changes in the Excel sheet itself in case you ever need to re-provision or re-create the environment.
    3. This is also extremely helpful when planning new property additions, or when working with external parties that need this data.
Change Default Page of MySite
Since your organization may not be using the Feeds or Activity features of SharePoint 2010 in phase 1 it makes sense to change the default page for MySite/Profiles to reference the profile page instead.
To change the default home page of the MySite Host Site Collection open the site collection in SharePoint Designer (you need to be a site collection owner of the my site host). After the site collection has been opened click on all files on the left hand side.
In the right main area you should see a bunch of items. One of these items will be default.aspx which is the current default page. There is also a person.aspx which is our desired default page. Select person.aspx and then in the ribbon click “set as home page”.
Modify Display of Status Message
Since the status message will give an error (due to it being disabled in the user properties) we need to load SharePoint Designer and edit the person.aspx page that we set as the default page.
To do this go back to SharePoint Designer and click the hyperlink for person.aspx this time and it will open in edit mode. Since we want to change settings set in the site definition we need to edit in Advanced Mode. To do this select Advanced Mode from the ribbon so that the page loads in advanced editing mode.
clip_image001
Once that is done the page will refresh and all of the code is now editable. Find the following div tag (surrounding StatusNotesControl) and hide it (using style=”display:none”) or comment it out.
clip_image002
Save your changes.
Close SharePoint Designer and go to your user profile. The Status Message control is not displayed.
To Remove Add As Colleague Button
The following can be added to the MySite Masterpage or appropriate CSS file to hide the ‘Add As Colleague’ button.
To Hide Social Webparts
There are a 3 social webparts that should be hidden by editing the person.aspx page in SharePoint.
  1. Navigate to a user profile.
  2. Click Site Actions > Edit Page.
  3. Click on the Ask Me About Webpart Header
  4. In The Ribbon Select Web Part Properties
  5. Expand Layout Section
  6. Check Hidden
  7. Click OK
  8. Click on the Recent Activities Webpart Header
  9. In The Ribbon Select Web Part Properties
  10. Expand Layout Section
  11. Check Hidden
  12. Click OK
  13. Click on the Note Board Webpart Header
  14. In The Ribbon Select Web Part Properties
  15. Expand Layout Section
  16. Check Hidden
  17. Click OK

Prerequisites SharePoint 2010 Social Networking


In this post on the SharePoint 2010 Social Computing feature-set, I am going to walk you through a number of prerequisites that have to be in place in your SharePoint environment before the social computing features will work at all.

(Note: This is the third post in this series. For the first post and a table of contents, go here.)


Before jumping into the details of the prerequisites, let me give you my master list of SharePoint 2010 Social Computing features that I plan to drill down into one by one during the next several posts:
  1. Tags
  2. Note Board
  3. Tag Profile pages
  4. Tags and Notes on My Site
  5. Tag search
  6. Tag and Notes bookmarklet
  7. Tag cloud web part
  8. Ratings
  9. Status Updates
  10. Activity Feed / Newsfeed
  11. Activity Feed preferences
  12. Recent Activities web part on My Site public profile
  13. Extensibility of Activity Feed
  14. Add Colleagues feature
  15. Keyword and Colleagues Suggestions feature
  16. “Interests” field on User Profile record
  17. “Ask Me About” field on User Profile record
  18. Integration with Outlook 2010
  19. People search
All of these features are part of the SharePoint 2010 Social Computing feature-set, and, as I pointed out in my first post in this series, are intended to help organizations do a better job at knowledge networking.

After months of searching the Internet, I have found a lot of articles on many of these features, but I haven’t found a comprehensive series of articles that really aims to go both broad and deep into the subject area. That’s my goal with this series of articles, and you can look forward to many more after this one that will step you through the details of all of the features in the list above.
SharePoint Server 2010 Prerequisites for Social Computing

As you might expect from the long list of features I show above, there is a lot going on “under the hood” in SharePoint Server 2010 to enable the social computing features. My experience is that it can be a challenge to get all of the prerequisites properly set up. It can also be a challenge to figure out what component is configured improperly when troubleshooting problems once the features have already been deployed to the users.

The infrastructure prerequisites generally fall into two categories: 1) Service Applications and 2) Timer Jobs. Therefore, I’ll break up my discussion into those two categories.
Service Applications Required

It is not so obvious at first glance what service applications are required to be configured and running to enable the social computing features in SharePoint 2010. There are two: 1) the Managed Metadata service application, and 2) the User Profile service application. Neither of them has the term “social” in their names, but nevertheless, you have to have both of them properly configured and running.

A couple of visual clues that there may be something wrong with one or both of these services is to take a look at any SharePoint page in your environment where you expect the social computing features to be available. You should see the icons for “I Like it” and “Tags and Notes”:

image

You should also see the “My Site” and “My Profile” menu items on the drop down menu for the user control on the page:

mcive0bh

If you don’t see all or some of these visual clues, then you need to proceed to Central Administration and determine if you have instances of the Managed Metadata service and the User Profile service running in your farm. (Note: SharePoint 2010 does not give the user an error message if these services are not running. It just doesn’t display the features that these services enable.)

It’s easy to see if you have instances of these services running in your SharePoint 2010 farm. Just go to Central Administration and navigate to the Manage Service Applications page to see if they have been provisioned and are running:

dipeqd10

21gyimlx

If you don’t have these service applications running in your SharePoint 2010 farm, then you will need to provision them by clicking on the New icon:

image

Explaining the configuration pages for these two services is beyond the scope of this article, but you should be able to easily find a number of articles that will walk you through the configuration steps.
Why does the Managed Metadata Service have to be running?

You might be wondering why it is necessary to have the Managed Metadata service application provisioned in order to use the social computing features? The reason is that the “tags” that users create when tagging pages, documents, list items, etc., get stored in the Keywords portion of the Term Store (which is the name of the central metadata repository that is maintained by the Managed Metadata service).

The Keywords portion of the Term Store is only half of the Managed Metadata repository. The other half is frequently referred to as the Taxonomy portion of the Term Store. The Taxonomy portion of the Term Store is hierarchical, while the Keywords portion is random. The master list of user tags gets stored randomly as they are created in the Keywords portion of the Term Store:

q352twyv

If the Managed Metadata service is not provisioned and running, users can’t use the social tagging features, because SharePoint 2010 has nowhere to maintain a master list of tags. One way to recognize that the Managed Metadata service is not provisioned/running properly is when your SharePoint site looks like this:

4n4cibpc

25gr1zux

If you see this behavior in your SharePoint 2010 site, the first place to look is in Central Administration to verify that the Managed Metadata service is running.

One more point before moving on to the User Profile service application. I have been referring to the Keywords portion of the Managed Metadata Term Store as the place that SharePoint 2010 stores the “master list” of user tags. This is an important concept to understand, and here is a little more detail.

Each time a user starts to tag an item in SharePoint 2010, the Keywords portion of the Term Store is queried in real time to see if suggestions can be made to the user about previous keywords that other users have used. If a keyword appears in the list of suggestions and the user deems it suitable, the user can use it to tag the item. If not, the user can add their own unique keyword to the Keywords store and then it will be available for SharePoint 2010 to use as a suggestion in the future for other users.

So, the Keywords portion of the Term Store only stores one instance of a given keyword. That instance may be used by many users and many times as they tag items throughout SharePoint. Therefore, the Keywords list in the Term Store is truly a master list of unique keywords.
What does the User Profile Service Application Have to Do with SharePoint 2010 Social Computing?

The short answer is, “just about everything”. All of the plumbing to make the social computing features work in SharePoint 2010 is built into the User Profile service application.

When you provision the User Profile service application, the SQL Server database gets created that is needed to store all of the social data. And, that database contains a long list of tables that are required to make social computing work:

qj0cy3ec

You can see from this screen shot that there are a number of tables that have names that that are fairly easy to figure out what feature of social computing they relate to. The “socialtag” tables relate to Tagging, the “socialcomments” tables relate to the Note Board, and the “socialratings” tables relate to the Ratings feature. So, this database needs to get created and that is one big part of what happens when you provision the User Profile service application in Central Administration.

The basic concepts of the User Profile service have been around since SharePoint Portal Server 2003. It was enhanced significantly in MOSS 2007. But, in both prior versions, the User Profile service’s primary scope and focus was to manage SharePoint’s User Profile database, synchronize it with a directory service (such as AD), and configure My Sites. In SharePoint 2010, the User Profile service continues to perform these roles in addition to providing the social computing infrastructure.

If you want to take advantage of the social computing features in SharePoint 2010, you will also need to properly configure the User Profile database
and properly configure My Sites. The social computing features will not work without User Profiles and My Sites working.

If your User Profiles and My Sites are not set up and/or working properly, you will easily be able to tell by a user control that looks like this:

safuj1jb

As I mentioned earlier in the article, the user control looks like this when User Profiles and My Sites are set up and working:

mcive0bh
Timer Jobs Required

A fairly long list of timer jobs get provisioned and scheduled when you provision the User Profile service application in SharePoint 2010. Timer jobs have long been utilized in SharePoint Products and Technologies and it seems like with every new version of SharePoint, the list of timer jobs at least doubles. Timer jobs are processes that need to run on a schedule in the background to aggregate information, clean up data, and perform other process-oriented tasks.

In the case of SharePoint 2010, the User Profile service provisions 13 timer jobs:

image

(You can find the timer job list and definitions under Timer Job Definitions in the Monitoring section in SharePoint 2010 Central Administration).

Microsoft does not provide a lot of documentation on what each of the timer jobs do in SharePoint 2010. So, it is a little difficult to say which of these timer jobs is responsible for doing a particular task that is important to the proper functioning of a specific social computing feature. Nevertheless, it is safe to say that the following User Profile Timer Jobs need to be running on an appropriate schedule in order for social computing to work properly:
  • Social Data Maintenance Job
  • Social Rating Synchronization Job
  • My Site Suggestions Email Job
  • Activity Feed Job
  • Activity Feed Cleanup Job
In the previous paragraph, I mentioned the idea of “appropriate schedule”. It has been my experience that the out-of-the-box schedule for some of these timer jobs may not be appropriate in all situations. Certainly, in a demonstration/test scenario, the out-of-the-box schedules don’t work very well. Too much time is allowed between runs of some of the timer jobs to process the data and present the results back in the user interface on a timely basis. Even in some production environments, the out-of-the-box schedule may not produce fast enough results to suit the users.

 Here are the default schedules for the five social-oriented timer jobs I listed above:

image

image

image

image

image

You are free to change the schedule for any or all of these timer jobs that relate to social computing. In my demo/testing environments I routinely set them all to run every three minutes. Obviously, I would want to be very thoughtful in making changes to schedules in a production environment and consider the needs of my users and the server resource availability as well.

That’s it for the prerequisites for the SharePoint 2010 Social Computing features. By now, you should see that making all of these features work together and accomplish their purposes requires quite a lot of technical infrastructure “under-the-hood”. Hopefully, this article will help you make sure you have all of the right components provisioned from the start and/or help you troubleshoot problems that your users may surface as they are using the social computing features.

In my next post, I will drill into the the details of what Tags are intended to be used for in SharePoint 2010 and exactly how they work.

Friday, November 2, 2012

Customizing SharePoint 2010 global navigation with Css


The global navigation in SharePoint is an important factor for the SharePoint site, this navigation are there to help orient users so they easily can move around the site. So when it comes to branding and customizing a SharePoint site it´s one of the key factors. When you branding the global navigation don´t forget to think simple but attractive, users may use the site navigation more than they use the search to find information.
In SharePoint 2010 the global navigation renders with unordered lists and list items (UL and LI), which gives us a simpler and more standard way for customization, especially compared to previous versions of SharePoint when the navigation rendered in a nestled table markup. There are a couple of ways and tools when it comes to build a custom navigation in SharePoint. The central point for the navigation is the functionality and the look and feel that means that we have to deal with CSS 2.1 or 3.0 and the SharePoint ASP menu control and its data source


The options we have depend of the needs, but also the approach you choose depends if we talking about a public faced web site or an Intranet.
  • Use the OTB control with changed settings
  • Extend the OTB menu control with custom Css 2.1 or 3.0
  • Extend the OTB menu control and hook it up with custom jQuery
  • Extend the OTB menu control with a custom site map provider
  • Code a new navigation control, and use a technique like Silverlight
  • Use a complete stand-alone navigation with jQuery that isn’t connected to SharePoint
There is a lot to think about when it comes to customization of the SharePoint global navigation so therefore I´ll split this article in the minimum of three articles. So here´s the plan:
  1. Introduction and How to customize the global navigation with CSS 2.1 and 3.0 (this post)
  2. How to customize the global navigation with custom CSS and how to use jQuery to work with feeling of the navigation, like animating a menu. Go there
  3. Tips and tricks about navigation settings, how to use different site map providers & multiple navigation providers, branding dropdown menus and more.

Below is a bunch of examples for customized navigation menus I have created specific for the article series. Of course, no guaranties for real cross browser CSS; these examples are mostly verified in IE 8 and Firefox 3.6.12, GC and Safari









Open up your SharePoint top site with your favorite tool SharePoint Designer 2010 and create a CSS file and put in a reference to this in a your (custom) master page. Put in the following line just below SharePoint:CSSlink tag in the master page.

1 "/Style Library/Blog/Blue.css" runat="server" After="corev4.css"/>

First off, a clean blue navigation with a smooth gradient background color. It has four properties for the background selectors and that´s because this is for various browsers. There are also a couple of extra classes below ‘Other stuff’ that you don´t need specific for the navigation. You can take those away if you prefer.



.s4-lp, body #s4-topheader2{
background-color:#2d9cc7; /*Fallback*/
background: -webkit-gradient(linear, left top, left bottom, from(#2d9cc7), to(#157db2));
background: -moz-linear-gradient(top, #2d9cc7, #157db2);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#2d9cc7, endColorstr=#157db2);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#2d9cc7, endColorstr=#157db2)";
margin-left:0px;
border-top:0px;
border-bottom:0px;
margin-left:0px;
}
.menu-horizontal{
margin-left:10px;
border-right: 1px #167FB3 solid;
background-image:none;
}
.menu-horizontal ul li{
color:#fff!important;
min-height:31px;
line-height:30px;
border:0px;
padding:0px;
margin:0px;
border-left:1px #167FB3 solid;
}
.menu-horizontal ul li a{
color:#fff!important;
font-weight:bold;
border:0px!important;
padding:0px!important;
margin:0px;
height:31px!important;
background-color:#2d9cc7; /*Fallback*/
background: -webkit-gradient(linear, left top, left bottom, from(#2d9cc7), to(#157db2));
background: -moz-linear-gradient(top, #2d9cc7, #157db2);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#2d9cc7, endColorstr=#157db2);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#2d9cc7, endColorstr=#157db2)";
padding-right:20px!important;
padding-left:20px!important;
}
.s4-toplinks .s4-tn > .menu-horizontal ul li a:hover {
text-decoration:none!important;
/*if use 333 the DD color will not work*/
color:#333!important;
background-color:#036ba8; /*Fallback*/
background: -webkit-gradient(linear, left top, left bottom, from(#036ba8), to(#4fb3d3));
background: -moz-linear-gradient(top, #036ba8, #4fb3d3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#036ba8, endColorstr=#4fb3d3);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#036ba8, endColorstr=#4fb3d3)";
height:31px!important;
border:0px;
padding:0px;
margin:0px;
}
.s4-toplinks .s4-tn > .menu-horizontal a.selected {
color: #fff!important;
background-color:#4fb3d3; /*Fallback*/
background: -webkit-gradient(linear, left top, left bottom, from(#4fb3d3), to(#036ba8));
background: -moz-linear-gradient(top, #4fb3d3, #036ba8);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4fb3d3, endColorstr=#036ba8);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#4fb3d3, endColorstr=#036caa)";
line-height:30px;
height:31px;
border:0px;
padding:0px;
margin:0px;
}
.menu-horizontal A.dynamic-children SPAN.additional-background {
background-image:none!important;
}
.s4-tn ul.dynamic {
background-image:none!important;
border:1px solid #f7f7f7;
border-top:0px;
border-bottom:1px solid #ccc;
margin:0px;
padding:0px;
}
.s4-tn li.dynamic {
background-image:none!important;
border-top:1px solid #ccc;
border-right:1px solid #ccc;
border-bottom:0px solid #ccc;
border-left:1px solid #ccc;
}
.s4-tn li.dynamic > .menu-item {
display:block;
padding-left:19px!important;
white-space:nowrap;
font-weight:normal;
background-color:#ffffff!important;
background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#f7f7f7))!important;
background: -moz-linear-gradient(top, #ffffff, #f7f7f7)!important;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffffff, endColorstr=#f7f7f7)!important;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffffff, endColorstr=#f7f7f7)"!important;
color:#333!important;
}
.s4-tn li.dynamic > a:hover {
background-color:#ffffff;
background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#ffffff))!important;
background: -moz-linear-gradient(top, #ffffff, #ffffff)!important;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffffff, endColorstr=#ffffff)!important;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffffff, endColorstr=#ffffff)"!important;
color: green!important;
}
/*----- Some other stuff -------*/
.col-fluid-1, .right-wp-zone-col {
 margin-top:20px
}
#s4-leftpanel-content {
padding-top:20px!important;
border-right:0px!important;
border-bottom:0px!important;
margin-right:0px;
margin-left:0px;
background-color:#f7f7f7!important
}
.s4-title{
min-height:70px;
padding:0px;
}
.s4-titlelogo{
padding-left:10px
}
TD.ms-sbscopes {
padding-right:0px
}
.s4-search, .s4-rp{
padding-top:3px!important;
margin-right:0px;
}
.s4-search TABLE {
margin-right:0px
}
.s4-title-inner{
background-color:#a0d9e6; /*Fallback*/
background: -webkit-gradient(linear, left top, left bottom, from(#a0d9e6), to(#f7f7f7));
background: -moz-linear-gradient(top, #a0d9e6, #f7f7f7);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#a0d9e6, endColorstr=#f7f7f7);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#a0d9e6, endColorstr=#f7f7f7)";
padding:0px 0px 0px 0px;
margin:0px;
min-height:70px;
}

download the images here.

/*---| By @Cstahl 2010 |---*/
.menu-horizontal{
margin-left:5px;
}
.menu-horizontal A.dynamic-children SPAN.additional-background {
background-image:none;
}
.menu-horizontal ul li{
text-align:center;
font-size:11px;
line-height:18px;
padding:0;
margin:0;
}
.menu-horizontal ul li a{
width:105px;
background-image:url('/_layouts/Images/tab.png');
background-position: 0 0;
background-repeat:no-repeat;
padding:0;
cursor:pointer;
color:#0a7285;
text-decoration:none;
}
.menu-horizontal ul li.active{
width:105px;
height:18px;
margin:0;
}
.menu-horizontal ul li.active a{
background-image:url('/_layouts/Images/TabActive.gif');
background-position: 0 0;
background-repeat:no-repeat;
color:#0a7285;
width:105px;
height:18px;
padding-top:8px;
}
.menu-horizontal ul li a:hover{
background-image:url('/_layouts/Images/TabActiveHover.gif');
background-position: 0 0;
background-repeat:no-repeat;
width:105px;
}
.s4-toplinks .s4-tn a.selected{
border-style: none;
border-color: inherit;
border-width: 0px;
background-image:url('/_layouts/Images/TabActive.gif');
background-position: 0 0;
background-repeat:no-repeat;
background-color: transparent;
width:118px;
height:16px;
color:#333;
margin-top:1px;
margin-right:1px;
margin-bottom:0px;
margin-left:1px;
}
.s4-tn ul.dynamic{
background-color:#f7f7f7!important;
border:1px solid #ccc;
border-top:0px;
margin-left:2px;
}
.s4-tn li.dynamic > .menu-item{
display:block;
padding:5px 10px;
white-space:nowrap;
font-weight:normal;
background-image:none;
text-align:left
}
.s4-tn li.dynamic > a:hover{
font-weight:normal;
background-color:#9FD8E6;
background-image:none;
}
/*----- Other stuff -------*/
.col-fluid-1, .right-wp-zone-col {
margin-top:20px
}
#s4-leftpanel-content {
padding-top:20px!important;
border-right:0px!important;
border-bottom:0px!important;
margin-right:0px;
margin-left:6px;
background-color:#f7f7f7!important
}
.s4-titlelogo{
padding-left:10px
}
.s4-title{
padding-left:0px;
}
TD.ms-sbscopes {
padding-right:0px
}
.s4-search, .s4-rp{
padding-top:2px!important;
margin-right:0px;
}
.s4-search TABLE {
margin-right:0px
}
.s4-title-inner{
background: -webkit-gradient(linear, left top, left bottom, from(#a0d9e6), to(#7ec1d0));
background: -moz-linear-gradient(top, #f7f7f7, #7ec1d0);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#a0d9e6, endColorstr=#7ec1d0);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#a0d9e6, endColorstr=#7ec1d0)";
padding:0px 0px 0px 0px;
margin:0px;
min-height:100px;
}
.s4-lp, body #s4-topheader2{
background-color:#7ec1d0;
margin-left:0px;
border-top:0px;
border-bottom:0px;
}






Tuesday, October 30, 2012

Show/Hide Lookup fields with jQuery


Show/Hide Lookup fields with jQuery
In my previous post i have introduced you about the hiding the fields using Jquery but that is for the normal site columns. If you are using the Lookup fields then you have to adopt some different approach.

I am just taking any example and explain you by this :

I am hiding the field in the SharePoint Edit Page based on the text value in below column.
Refer to the images that would explain you more clearly

What i am trying to do is when you enter the AU as a Text value in Test Value(Column) then the Test_Status(Column) will hide otherwise it is visible.




In above image Test_Status control is not visible.


In aboe image the control is visible.

Now comes the code :




Monday, September 17, 2012

Finding w3wp process id in SharePoint 2010


Go to CMD

Type cd c:\windows\system32\inetsrv

Type appcmd list wp

Powershell script to manage RemoteAdministratorAccessDenied


$snapin="Microsoft.SharePoint.PowerShell"
if (get-pssnapin
$snapin -ea "silentlycontinue") {
  write-host -f Green "PSsnapin
$snapin is loaded"
}

elseif
 (get-pssnapin $snapin -registered -ea "silentlycontinue") {
  write-host -f Green "PSsnapin
$snapin is registered"
  Add-PSSnapin
$snapin
  write-host -f Green "PSsnapin
$snapin is loaded"
}

else {

  write-host -f Red "PSSnapin
$snapin not found"
}

# get content web service

$contentService
= [Microsoft.SharePoint.Administration.SPWebService]::ContentService
# turn off remote administration security

$contentService.RemoteAdministratorAccessDenied
= $false
# update the web service

$contentService.Update
()

SharePoint 2010 : Set SSO credentials


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
using System.Configuration;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Administration.Claims;
using Microsoft.Office.SecureStoreService.Server;
using Microsoft.BusinessData.Infrastructure.SecureStore;

namespace Laxmikant
{
    public static class SecureStoreManagement
    {

        internal static SecureString MakeSecureString(string str)
        {
            if (str == null)
            {
                return null;
            }
            SecureString str2 = new SecureString();
            char[] chArray = str.ToCharArray();
            for (int i = 0; i < chArray.Length; i++)
            {
                str2.AppendChar(chArray[i]);
                chArray[i] = '0';
            }
            return str2;
        }


        internal static SecureStoreServiceApplicationProxy GetSecureStoreProxy()
        {
            string siteurl = ConfigurationSettings.AppSettings["SPSiteUrl"];//from app.config
            using (SPSite site = new SPSite(siteurl))
            {
                SPServiceContext context =
                    SPServiceContext.GetContext(site);//SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default);

                SecureStoreServiceApplicationProxy sssProxy = context.
                  GetDefaultProxy(typeof(SecureStoreServiceApplicationProxy)) as SecureStoreServiceApplicationProxy;


                return sssProxy;
            }

        }

        public static void SetCredentials(string userName, string userPassword, string targetApplicationID)
        {

            targetApplicationID = ConfigurationSettings.AppSettings["Name"]; //from app.config
            userName="SET USER NAME";
            userPassword="PASSWORD";
            IList creds = new List(2);
            creds.Add(new SecureStoreCredential(MakeSecureString(userName), SecureStoreCredentialType.WindowsUserName));
            creds.Add(new SecureStoreCredential(MakeSecureString(userPassword), SecureStoreCredentialType.WindowsPassword));

            using (SecureStoreCredentialCollection credentials = new SecureStoreCredentialCollection(creds))
            {
                SecureStoreServiceApplicationProxy sssProxy = GetSecureStoreProxy();
                if (sssProxy != null)
                {
                    SPClaim claim = SPClaimProviderManager.CreateUserClaim("farm admin username", SPOriginalIssuerType.Windows);
                    SecureStoreServiceClaim ssClaim = new SecureStoreServiceClaim(claim);
                    sssProxy.SetUserCredentials(targetApplicationID, ssClaim, credentials);

                    //if the target application  is using group type credentials then call this.//sssProxy.SetGroupCredentials(targetApplicationID, credentials);
                }
            }

        }

    }
}