Wednesday, November 5, 2008
Search Add-ons (Providers) on MOSS search result in IE7 / Firefox
First basics of search. I know the various ways how sharepoint handles search requests. Back from SPS 2003 configuration , advanced webpart development till Moss2007 integrated search.
For our purpose, we will use the query string keyword search( As other search options are postback with some compulsory parameters to the search result webpart in results.aspx page.
http://portal/searchcenter/Pages/Results.aspx?k=dhyan&Scope=All Sites.
<?xml version="1.0" encoding="utf-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Search corporate</ShortName>
<Description>Searching the Corporate MOSS sites</Description>
<Url type="text/html" template="http://portal/searchcenter/Pages/Results.aspx?k={searchTerms}&s=All%20Sites"/>
</OpenSearchDescription>
As it shows: k={key word you want to pass}, Scope= {The scope defined in the portal SSP or simple All sites}
Now you create a XML file with your notepad update the content given below and upload it to a document library in your moss. Its required to call the XML from your Fav. Browser so that it installs the XML configuration for your search Add-on.
Add javascript code in a file or in a content webpart of a page and publish it.
<a href="javascript:window.external.AddSearchProvider('http://portal/adp/pages/search_add.xml');">Add Corporate Search </a>
While I after uploading my XML file named as search_add.xml , I simply refreshed the page to show the link "Add Corporate Search". And it will ask for your permission to add in the search provider. Click "yes", and choose default search provider option
Now done you can do search on the keyword from your browser on your Moss installation site.
Thursday, October 30, 2008
Configure SSO for MOSS 2007
The steps i'm following what he wrote in his blog. its only for my future reference i'll come and see my blog incase he removes this valuable information.
There are seven main activities that we need to do:
1. Create the SSO service account -- This is the account that the service will run under.
2. Create the SSO groups -- These groups are used to control who has the ability to administer SSO (export the master key) and who has the ability to manage it (add/remove application definitions.)
3. Configure the SSO Service - Set SSO to start and get it to use the service account.
4. Configure SQL Server - Authorize the SSO service account to SQL server.
5. Manage SSO - Setup SSO in MOSS including the groups and the database.
6. Manage the encryption key -- Create the encryption key that will be used for protecting the username and password information on the system.
7. Manage settings for enterprise application definitions -- Define what initial applications SSO will be setup to manage passwords for.
We need to create an account for the "Microsoft Single Sign-on Service" (SSO Service) to run as. This account has to be a domain account that has local administrative privileges for the front end web servers, must be a member of the SharePoint group Farm Administrators, must have db_creator and security administrator roles in SQL Server, and must be a member of the group that is defined as SSO administrators.
Then add the user to the Domain Admins group( this is the missing link) in order to get the local administrator privileges requirement met.
# From the Start Menu click Administrative Tools-Active Directory Users and Computers
# In the left hand pane on the Users folder right click and select New-User from the menu that appears. If your organization places service accounts in a different organizational unit (OU) you can certainly add this account to that location.
# Enter the First Name (SharePoint SSO), Last Name (Service), and User logon name (SharePointSSOSvc) fields and click the Next button. You can name the account anything you want, however, these values make it clear what the account is used for.
#Enter the a password into the Password and Confirm password fields. Uncheck the User must change password at next logon checkbox. Check the User cannot change password and Password never expires checkboxes. Click the Next button. This sets the account up to be a service account.
# Click the Finish button.
# On the user that was just created, right click and select Properties.
#Click the Member Of tab.
#Click the Add button
# Enter the group name Domain Admins and click Check Names then click OK. As mentioned above, if you're using another group to provide local administrator access to the farm servers, use that group here.
# Click the OK button.
With the user account created and added to a group that will have administrative access to the farm servers. Next we need to create the groups that we'll add the users capable of managing SSO into.
Then Create the SSO Group.
rest of the steps are SKIPPED as it has to do with sharepoint configuration
The last step:
Manage Settings for Enterprise Application Definitions ( has to do in Sharepoint)
Sunday, October 5, 2008
Deploying asp.net user control in sharepoint
This is the same content that has been posted in http://bestofcyber.wordpress.com/2008/09/16/deploying-aspnet-usercontrolsascx-declared-in-custom-aspx-pages-into-moss-2007-sites/
Consider you are developing a custom application in asp.net out of the box SharePoint for the ease of UI development and deployment ,you might need to also create user controls and use into your aspx pages.
While you are deploying usercontrols(.ascx) file ,you can follow below steps to get the usercontrols rendering in the custom aspx pages I found this way more simple and working 100% fine.
1. Create a Directory called “UserControls” in the root of your SharePoint web site on the file system E.g. C:\Inetpub\wwwroot\wss\VirtualDirectories\80\UserControls
2. Open IIS manager and in the root of your SharePoint site create a VirtualDirectory called “_controls” and point it to that newly created directory.
3. Put your user control in that newly created directory on the filesystem.
4. Open the web.config file and add the following:
Also make sure the trustlevel entry is set to the below
5. In your ASPX page change the existing register directive with the following:
<%@ Register src=”~/_controls/SomeControl.ascx” TagName=”somecontrol” TagPrefix=”uc1″ %>
6. Run your ASPX page and your control should render correctly.
Tuesday, July 29, 2008
Dataformwebpart Server variables
http://dataformwebpart.com/2007/11/07/spd-2007-data-view-parameters-you-dont-know-about/
Thursday, July 10, 2008
Get Current User Email, Login, Display Name Details
The normal code which microsoft given fails:
SPWeb site = SPContext.Current.Web;Because most of the users who don't have access to All sites won't give details of their email by the code given. If you are wondering what is all about the difference between All users see below:
SPUser user = site.CurrentUser;
string DisplayName = user.Name;
string Login = user.LoginName;
string EMail = user.Email;
string User Notes = user.Notes;
SPWeb site = SPContext.Current.Web;The code gives 3 types of different user collection so i guess the user who logged in and didn't find his email by the code above belongs to one of this group.
SPUserCollection c1 = site.Users;
SPUserCollection c2 = site.AllUsers;
SPUserCollection c3 = site.SiteUsers;
The difference between these SPUserCollection is copied from MSDN.:
I used a basic way to get the current user using (context of control HTTPCONTEXT) Context.User.Identity.Name or Page.User.Identity.Name which does the same httpcontext.
After we get the current user login i can pass it to the magic of another Class in sharepoint object Model which brings the user details.
using Microsoft.SharePoint.Utilities;
SPWeb osite = SPContext.Current.Web;
SPPrincipalInfo prin = SPUtility.ResolvePrincipal(osite,Context.User.Identity.Name , SPPrincipalType.All, SPPrincipalSource.All, osite.AllUsers, false);
writer.Write(prin.Email);
using this method u can also search the user by their Email ID, or their Display name. its a cool method who does the search on multiple fields.
Tuesday, July 1, 2008
Use explicit casting instead of DataBinder.Eval
The DataBinder.Eval method uses .NET reflection to evaluate the arguments that are passed in and to return the results. Consider limiting the use of DataBinder.Eval during data binding operations in order to improve ASP.NET page performance. <tr> <td><%# DataBinder.Eval(Container.DataItem, "field1") %></td> <td><%# DataBinder.Eval(Container.DataItem, "field2") %></td> </tr> </ItemTemplate>
Consider the following ItemTemplate element within a Repeater control using DataBinder.Eval:
Using explicit casting offers better performance by avoiding the cost of .NET reflection. Cast the Container.DataItem as a DataRowView:
<ItemTemplate>
<tr>
<td><%# ((DataRowView)Container.DataItem)["field1"] %></td>
<td><%# ((DataRowView)Container.DataItem)["field2"] %></td>
</tr>
</ItemTemplate>
Thread Safe .NET Event Technique
public event EventHandler Updated = delegate { };
protected void UpdatePrice(string mySymbol, decimal newPrice, long newVolume)
{
_priceList[mySymbol] = newPrice;
_volumeList[mySymbol] = newVolume;
Updated(this, new MarketFeedEventArgs(mySymbol, newPrice, newVolume));
}
Because in case of multithreaded environment if the event updated is not subscribed or if null it. Removes the subscription from all the other event handler. So instead of making a new copy of event each time, we should initialize the events at the first case.
People normally use like this which is performance friendly but not good practice for multithreaded environ
public event EventHandler Updated;
protected void UpdatePrice(string mySymbol, decimal newPrice, long newVolume)
{
_priceList[mySymbol] = newPrice;
_volumeList[mySymbol] = newVolume;
if(Updated != null)
Updated(this, new MarketFeedEventArgs(mySymbol, newPrice, newVolume));
}
How to check email works without using SMTP
You can find your mails posted in the directory mentioned below after you send a mail by code.
<system.net>
<mailsettings><smtp deliverymethod="SpecifiedPickupDirectory"> <specifiedpickupdirectory pickupdirectorylocation="c:\Test\">
</smtp>
</mailsettings>
</SYSTEM.NET>
Source of this tip : http://dotnettipoftheday.org/tips/smtp-delivery-methodSpecifiedPickupDirectory.aspx
Monday, June 30, 2008
Add Custom Words in Sharepoint Spell Checker
Today after a struggle for 15 mins, i found the solution to add up your own custom dictionary words in sharepoint. No worries now u can tell spell checker to ignore your love words.
Oh ok Back to the point.
1) Create a document library in your root site of your publishing folder ( this is where you will get your spelling feature), and give the name of the library as "Spelling".
2) Then upload a text file named “Custom Dictionary.txt”. Put your magic dictionary words separated by a single line. That is each words in each line.
There you go, do a IISRESET you are done..
DO post your comments if you find this helpful.
Add SharePoint List Items with InfoPath
So i tried many options with Infopath forms and yet amazed with its cool capabilities of quick form creation with all the form validation and also your custom Javascript code to actually submitting a form with MsXML xmlhttp request. Cool.
Ok now here is a good article written by Matt how to create a form to insert or update a sharepoint list item using its Lists.asmx webservice.
And its easy to display to show the details of your list also, its like ur OLD buggy SPD.
http://www.infopathdev.com/blogs/matt/archive/2006/02/02/Add-SharePoint-List-Items-with-InfoPath.aspx
Friday, June 27, 2008
New Buzz
http://www.networkworld.com/community/node/29262?hpg1=bn
Sharepoint DataFormWebPart as Dropdownlist
Current client has no resources to maintain the webparts or build a new one so he is totally dependant of The (Gruesome) Buggiest SOftware in the market.
Ladies and gentleman may i present MOSS Designer.
Now how do i build dropdown which values has to be populated form a list located in different site and that too has to be filtered according to the paramater passed as selectedvalue of another dropdownlist as postback.
Simple ... The only powerful control in sharepoint designer is DataFormWebpart. Man you can design , capture , gather any information from any sitecollection located in the portal with this webpart, that too without writing a code.
So i used it to add the iterate the records and populate to my dropdown with the help of a powerful version on spdatasource . No wonder you have to work on the formating inside the XSL tags.
Thursday, June 26, 2008
Sharepoint Custom DateTimeField control
I searched a lot in blogs and google for this BUG from Microsoft till 07 Apr 2008 because thats when i have to write my own custom control. You can't use the datetimefield in SPControlMode.Display.
Here it goes:
public class myDateTime : DateTimeField
{
protected override void RenderFieldForDisplay(HtmlTextWriter output)
{
if (base.ControlMode == SPControlMode.Display)
{
if (base.ItemFieldValue != null)
output.Write(((DateTime)base.ItemFieldValue).ToShortDateString());
}
else
{
base.RenderFieldForDisplay(output);
}
}
}
Hey do post some comment if it helps you anyway !!
Sharepoint Lookup Field values
Lets consider you require to display the values of lookup field for your webpart form in a dropdown.
You can use it in your dropdown datasource:
where field is SPField and list is SPList
DropDownList ddl = new DropDownList();
ddl.ID = field.Id;
ddl.DataSource = DataSource(field, list);
Here it goes :
public ICollection DataSource(SPField Colfield, SPList lookupList)
{
string lookupField;
int num = 0;
SPFieldLookup lookup = (SPFieldLookup)Colfield;
lookupList = lookupList.ParentWeb.Lists[new Guid(lookup.LookupList)];
if (lookup != null)
{
lookupField = lookup.LookupField;
if (string.IsNullOrEmpty(lookupField))
{
lookupField = "Title";
}
}
else
{
return null;
}
DataTable table = new DataTable();
table.Columns.Add(new DataColumn("ValueField", typeof(int)));
table.Columns.Add(new DataColumn("TextField", typeof(string)));
if (!lookup.Required && !lookup.AllowMultipleValues)
{
DataRow row = table.NewRow();
row[0] = 0;
row[1] = SPResource.GetString("LookupFieldNoneOption", new object[0]);
table.Rows.Add(row);
num++;
}
if (lookupList != null)
{
try
{
SPField field = lookupList.Fields.GetField(lookupField);
SPQuery query = new SPQuery();
StringBuilder builder = new StringBuilder("
builder.Append("\"/>
builder.Append("\"/>
query.ViewXml = builder.ToString();
SPListItemCollection items = lookupList.GetItems(query);
for (int i = 0; i < items.Count; i++)
{
string fieldValueAsText = field.GetFieldValueAsText(items[i][lookupField]);
if (!string.IsNullOrEmpty(fieldValueAsText))
{
DataRow row2 = table.NewRow();
row2[0] = items[i].ID;
row2[1] = fieldValueAsText;
table.Rows.Add(row2);
num++;
}
}
return new DataView(table);
}
catch (ArgumentException)
{
return null;
}
}
return null;
}
Don't forget to put your comments if it helps you
Today I got my 22" LCD Monitor
After a month of request today i got my new 22" LCD monitor. Its awesome considering the comfort of viewing everything in a broader view.
Well now i can do some more serious coding, unfortunately i can't use it view my movie collection as I can't carry it home :)