Thursday, April 30, 2009

Making Changes to MOSS and WSS Accounts and Passwords

Making Changes to MOSS and WSS Accounts and Passwords

Perform these changes in the order listed below to modify the service accounts for Windows SharePoint Services (WSS) v3.0 or Microsoft Office SharePoint Server (MOSS) 2007. The first section is for WSS and the second is MOSS. They are mostly the same with some minor changes in each.



WSS Environments:


Central Admin AppPool
Make this change via the command line


Stsadm –o updatefarmcredentials –userlogin -password
Other Website AppPools
Make this change via the command line

Stsadm –o updateaccountpassword –userlogin -password [-noadmin]
Use –noadmin if the Central Admin AppPool is the same account as other Web AppPools
WSS Search
Make this modification via the Central Administration website

Central Administration website > Operations > Services on Server > Windows SharePoint Services Search
Update the Configurable Password In Service Account AND\OR Content Access Account as Needed


MOSS Environments:

Central Admin AppPool
Make this change via the command line


Stsadm –o updatefarmcredentials –userlogin -password


Other Web Front End AppPools
Make this change via the command line


Stsadm –o updateaccountpassword –userlogin -password [-noadmin]
Use –noadmin if the Central Admin AppPool is the same account as other Web AppPools
Microsoft Office SharePoint Server Search
Make this modification via the Central Administration website

Central Administration website > Operations > Services on Server > Office SharePoint Search
Update the password in Service Account
Office 2007 SSP & Excel
Make this modification via the Central Administration website

Central Administration website > Application Management > Create or Configure This Farm's Shared Services > Hover over SSP in Farm > Edit Properties > Update the SSP Service Credentials
Office Server Crawl/Index Account
Make this modification via the Central Administration website

SSP Admin UI -> Search Settings -> Default Content Access Account
Update Account and PW as needed
Notes
Stsadm –o updatefarmcredentials and stsadm –o updateaccountpassword should do the trick for everything but the SSPs. Run updateaccountpassword across on specific boxes if you are having NLB or connection issues

Central admin app pool ID - Database Access Account:
Make this change via the command line

stsadm.exe -o updatefarmcredentials -userlogin -password
Other Application Pool IDs:
Make this change via the command line

Stsadm.exe –o updateaccountpassword –userlogin -password [-noadmin]
SSP Service credentials
Making Changes to MOSS and WSS Accounts and Passwords

Central Administration website > Application Management > Manage this Farm's Shared Services > access the ECB for the SSP you need to change > click on "Edit Properties" > on "Edit Shared Services Provider" page, in "SSP Service Credentials" set the account/password (also set the account/password for any Process account that need access to the SSP (typically done when configuring IFSS)
Command Line
stsadm.exe -o editssp
-title
[-newtitle ]
[-sspadminsite ]
[-ssplogin ]
[-ssppassword ]
[-indexserver ]
[-indexlocation ]
[-setaccounts ]
[-ssl ]

MOSS Search Service credentials:
Two options

Central Administration website -> Operations > Services on Server > Office SharePoint Server Search > update the account information in the "Service Account" section
stsadm -o osearch -farmserviceaccount -farmservicepassword
WSS Search Service credentials:
Two options

Central Administration website > Operations > Services on Server > Windows SharePoint (help) Search > update the account information in the "Service Account" section and in the "crawl account" section
stsadm -o spsearch -farmserviceaccount -farmservicepassword
MOSS SSO:


Use the SCM to update the password for the SSO service account; restart SSO Service
Once this is done, open the Central Administration website > Operations > Manage settings for Single Sign-On > update account information
Profile Import account:

SSP Admin > User profiles and properties > Configure Profile Import > update account information in the "default access account" section
Excel: Should be re-set when you change the information for the SSP Service account

Monday, April 27, 2009

Remove Orphan Entries From Sharepoint 2007

Step1: Run the given sql Query.
Reference URL: http://blogs.technet.com/corybu/

Copy Follwoing Code:
Use MSDB
Drop table orphanlist

CREATE TABLE [dbo].[orphanlist](
[farm] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[databasename] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[SiteID] [uniqueidentifier] NULL,
[sitepath] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[type] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
)

drop table orphan_hopper
declare
@dbname as varchar(250),
@cmdstr as varchar(2000),
@dbid as varchar(250),
@configdb as varchar(250)

/** only change the following line and nothing else, change spskills_config_db to your config db name **/
select @configdb = 'spskills_config_db'

/** Change nothing below this line **/
select @cmdstr =
'select distinct b.name as ''databasename'', b.id as ''dbid'' into orphan_hopper
from
[' + @configdb + '].dbo.sitemap as a inner join
[' + @configdb + '].dbo.objects as b on a.databaseid=b.id inner join
[' + @configdb + '].dbo.objects as c on c.id=a.applicationid inner join
[' + @configdb + '].dbo.objects as d on b.parentid=d.id inner join
[' + @configdb + '].dbo.objects as e on d.parentid=e.id '
exec (@cmdstr)

DECLARE DBCursor CURSOR For
Select databasename, dbid
From orphan_hopper

OPEN DBCursor
FETCH NEXT FROM DBCursor into @DBName, @dbid

WHILE @@FETCH_STATUS =0
BEGIN
INSERT INTO orphanlist([Type], farm, databasename,[sitepath], SiteID)
EXEC
('
select ''Potential ConfigDB orphan:'' + '''+@dbname+''' as [Type], '''+@configdb+''' as [farm], '''+@dbname+''' as [databasename],path as [sitepath], id as [SiteID] from ['+@configdb+'].dbo.sitemap where id not in (select id from ['+@dbname+'].dbo.sites) and databaseid = '''+@dbid+'''
union
select ''Potential ConfigDB orphan:'' + '''+@dbname+''' as [Type], '''+@configdb+''' as [farm], '''+@dbname+''' as [databasename],path as [sitepath], id as [SiteID] from ['+@configdb+'].dbo.sitemap where id not in (select siteid from ['+@dbname+'].dbo.webs where parentwebid is null) and databaseid = '''+@dbid+'''
union
select ''Potential ContentDB orphans:'' + '''+@dbname+''' as [Type], '''+@configdb+''' as [farm], '''+@dbname+''' as [databasename],fullurl as [sitepath], siteid as [SiteID] from ['+@dbname+'].dbo.webs where parentwebid is null and siteid not in (select id from ['+@configdb+'].dbo.sitemap where databaseid = '''+@dbid+''')
union
select ''Potential ContentDB orphan:'' + '''+@dbname+''' as [Type], '''+@configdb+''' as [farm], '''+@dbname+''' as [databasename],fullurl as [sitepath], siteid as [SiteID] from ['+@dbname+'].dbo.webs where parentwebid is null and siteid not in (select id from ['+@dbname+'].dbo.sites)
')
FETCH NEXT FROM DBCursor into @DBName, @dbid
END
CLOSE DBCursor
DEALLOCATE DBCursor

select * from orphanlist



Step2: Delete the Content DB
stsadm.exe -o deletecontentdb -url http://ServerName -databasename wss_content -databaseserver ServerName
Operation completed successfully.

Step3: Add Content DB
stsadm.exe -o addcontentdb -url http://ServerName -databasename wss_content -databaseserver ServerName
Operation completed successfully.

Friday, April 24, 2009

Exception from HRESULT: 0x80040E14

Exception from HRESULT: 0x80040E14
If any of you have come across this error "Exception from HRESULT: 0x80040E14" while trying to do a STSADM restore, it's a very simple problem. It means the SQL server has run out of space for either the logs or the data file. Simply delete some un-needed files from the HDD that the SQL server is writting to and it fixes the problem.

Tuesday, April 7, 2009

Sharepoint 2007 Custom Search

Points we need to make sure before using Search Option

Open the project "SharePoint.Search".
Go to the method "ExecuteFullTextSqlQuery" In SearchResults.ascx.cs page, where we can see query which retrieves data

"SELECT FileExtension, Rank, ContentClass, Path, Title, Abstract, IsDocument FROM SCOPE()"

Go to Central Administration,

Shared Services Administration: SharedServices1 > Search Settings > Managed Properties

Open Metadata Property Mappings page

Check All the fields which is specified in the query exist or not .

If the fields doesn't exist, go to New Managed Property at the top and add the field.

Check the checkbox "Use in Scope"

Common errors which may occur are :

Property doesn't exist or is used in a manner inconsistent with schema settings.
Possible reason : Field doesn't exist in Metadata Property Mappings

Your query is malformed. Please rephrase your query
Possible reason : Query is nor formatted properly

After doing this, again if the data is not coming, Comment the line
//sbFullTextSqlQuery.Append(" \"Scope\" = '" + _scope + "' ");

Because this may give error as "Scope in your query does not exist"

To know more about how this works, check this links

http://msdn2.microsoft.com/en-us/library/bb608305.aspx
http://www.ureader.com/msg/12294188.aspx




The code below says about how we can customize sharepoint search option


protected void btnSearch_Click(object sender, EventArgs e)
{
ResultTableCollection resultTableCollection = FetchRelevantSearchResults();
ResultTable relevantResultsResultTable = resultTableCollection[ResultType.RelevantResults];

DataTable relevantResultsDataTable = new DataTable();
relevantResultsDataTable.Load(relevantResultsResultTable, LoadOption.OverwriteChanges);

if (relevantResultsDataTable != null)
{
grdSearch.DataSource = relevantResultsDataTable;
grdSearch.DataBind();
}

}
// Fetch search result
private ResultTableCollection FetchRelevantSearchResults()
{
ResultTableCollection resultTableCollection = null;

SPSecurity.RunWithElevatedPrivileges(delegate()
{
try
{
ExecuteFullTextSqlQuery(out resultTableCollection);
}
catch (Exception ex)
{

}
});

return resultTableCollection;
}

// Call CAML query
private void ExecuteFullTextSqlQuery(out ResultTableCollection resultTableCollection)
{
// Guid _currentSiteGuid = SPContext.Current.Site.ID;



//using (SPSite _SPSite = new SPSite(_currentSiteGuid))
//http://mossdev:6076
//http://mossdev:35643/
using (SPSite _SPSite = new SPSite("http://mossdev:35643"))
{
using (FullTextSqlQuery _FullTextSqlQuery = new FullTextSqlQuery(_SPSite))
{
_FullTextSqlQuery.StartRow = 0;
_FullTextSqlQuery.RowLimit = 2;
_FullTextSqlQuery.HighlightedSentenceCount = 3;
_FullTextSqlQuery.EnableStemming = true;
_FullTextSqlQuery.TrimDuplicates = true;
_FullTextSqlQuery.Culture = CultureInfo.CurrentCulture;
_FullTextSqlQuery.KeywordInclusion = KeywordInclusion.AnyKeyword;
if (SPSecurity.AuthenticationMode != AuthenticationMode.Windows)
{
_FullTextSqlQuery.AuthenticationType = QueryAuthenticationType.PluggableAuthenticatedQuery;
}
else
{
_FullTextSqlQuery.AuthenticationType = QueryAuthenticationType.NtAuthenticatedQuery;
}
_FullTextSqlQuery.ResultTypes = ResultType.RelevantResults;

StringBuilder sbFullTextSqlQuery = new StringBuilder(string.Empty);
sbFullTextSqlQuery.Append("SELECT ");
sbFullTextSqlQuery.Append(" FileExtension, Rank, ContentClass, Path, Title, Abstract, IsDocument ");
sbFullTextSqlQuery.Append("FROM ");
sbFullTextSqlQuery.Append(" SCOPE() ");
sbFullTextSqlQuery.Append("WHERE ");
sbFullTextSqlQuery.Append(" FREETEXT(defaultproperties, 'raj') ");
sbFullTextSqlQuery.Append("AND ");
sbFullTextSqlQuery.Append(" \"Scope\" = 'Knowledge Objects' ");
sbFullTextSqlQuery.Append("AND ");
sbFullTextSqlQuery.Append(" ( ");
sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_DocumentLibrary') ");
sbFullTextSqlQuery.Append(" OR ");
sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_850') ");
sbFullTextSqlQuery.Append(" OR ");
sbFullTextSqlQuery.Append(" (ContentClass = 'STS_Web') ");
sbFullTextSqlQuery.Append(" ) ");
sbFullTextSqlQuery.Append("ORDER BY ");
sbFullTextSqlQuery.Append(" Rank DESC ");
// sbFullTextSqlQuery = new StringBuilder();
//sbFullTextSqlQuery.Append("SELECT Title, Abstract, Rank FROM scope() WHERE scope='All Sites' ");

//sbFullTextSqlQuery.Append("SELECT Account,CreatedBy FROM scope() ");

// fields needs mapping Title,Abstract,

// sbFullTextSqlQuery.Append("SELECT FileExtension, Rank, contentclass, Path,IsDocument FROM SCOPE() WHERE FREETEXT(defaultproperties, 'company') AND Scope = 'Knowledge Objects' AND ( (IsDocument = 1 AND ContentClass = 'STS_ListItem_DocumentLibrary') OR (IsDocument = 1 AND ContentClass = 'STS_ListItem_850') OR (ContentClass = 'STS_Web') ) ORDER BY Rank DESC") ;

//sbFullTextSqlQuery.Append("SELECT FileExtension,contentclass,Rank,Path,IsDocument FROM SCOPE() WHERE FREETEXT(defaultproperties, 'company')");
//sbFullTextSqlQuery.Append("AND ");
//sbFullTextSqlQuery.Append(" ( ");
//sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_DocumentLibrary') ");
//sbFullTextSqlQuery.Append(" OR ");
//sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_850') ");
//sbFullTextSqlQuery.Append(" OR ");
//sbFullTextSqlQuery.Append(" (ContentClass = 'STS_Web') ");
//sbFullTextSqlQuery.Append(" ) ");
//sbFullTextSqlQuery.Append("ORDER BY ");
//sbFullTextSqlQuery.Append(" Rank DESC ");



//sbFullTextSqlQuery.Append("SELECT ");
//sbFullTextSqlQuery.Append("Title,Abstract, FileExtension, Rank, ContentClass, Path,IsDocument ");
//sbFullTextSqlQuery.Append("FROM ");
//sbFullTextSqlQuery.Append(" SCOPE() ");
//sbFullTextSqlQuery.Append("WHERE ");
//sbFullTextSqlQuery.Append(" FREETEXT(defaultproperties, 'company') ");

_FullTextSqlQuery.QueryText = sbFullTextSqlQuery.ToString();

resultTableCollection = _FullTextSqlQuery.Execute();
}

_SPSite.RootWeb.Dispose();
}
}