Sunday, December 16, 2018

Chain of Responsibility Pattern

Chain of Responsibility Pattern (Behavioral Patterns) describes how we handle a single request by a chain of multiple handler objects. The request has to be processed by only one handler object from this chain. If the current handler object is able to process the request, then the request will be processed in the current handler object; otherwise, the current handler object needs to shirk responsibility and push the request to the next chain handler object.


Thursday, December 13, 2018

Factory Method is Creational Pattern. It define an interface which will creating an object, but let subclasses decide which class to instantiate. Factory method pattern returns the instance of a class at run-time depends on the condition/login users/role of user and so on.

Wednesday, October 5, 2011

Configure incoming Email setting in the SharePoint server

Configure incoming Email setting in the SharePoint server

1. Need to installed SMTP server on the SharePoint server.
2. Configure SMTP with following settings.

To configure the SMTP server:
a. On the Start menu, run Administrative Tools\Internet Information Services (IIS) 6.0 Manager.

b. Right click Default SMTP Virtual Server in the left pane, and click Properties.

c. Click Authentication on the Properties dialog box’s Access tab.



d. Return to the Access tab and click Relay.

e. Select All except the list below and Allow all computers..., as shown in Figure.



f. On Properties dialog box’s Delivery tab, click Outbound Security.

g. Select Integrated Windows Authentication and provide the appropriate credentials, as shown in Figure.



h. Return to the Delivery tab and click Advanced.

i. In the Advanced Delivery dialog box, as shown in Figure 23, enter the SMTP host name in the Smart host field.




3. Start “Microsoft SharePoint Foundation Incoming E-Mail” service from “Manage services on server” link in Central Admin.

4. Configure the incoming mail setting from the Central Admin as shown below. Note that Email Server display address should be the FQDN of the SharePoint server. Here is ‘XXXX.domain.com’




5. Configure the Document Library which received mails. Create Document library with same name as the mail alias and do setting as shown below. Incoming mail should be any id.



6. Then sent mail to Id specified in ‘Incoming mail’, this mail will come in the drop location and SharePoint Timer job will pick that mail and add it to the list created above.


Constraint:


1. Incoming mail id should be “@FQDN_of_server.Domain.com”, these explain in above step 4.

Friday, October 2, 2009

Some helpful STSADM command

Some helpful STSADM command

----Starting Service MSSQLServer...
NET START "SQL Server (MSSQLServer)"

----ECHO Resetting IIS...
"C:\WINDOWS\system32\iisreset.exe"

----Creating Roles and Membership database...
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql" -S <SQL Server Name> -E -d "<DB Name>" -A all

----Copying **** config file
CD C:\Vinod\folder1
COPY /Y ****.xml "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\CONFIG"


----Installing and activating
STSADM -o activateFeature -filename *\feature.xml -url <Web app URL with Port> -force
----Deploy *.wsp solution package
--First adding solution package to farm...
STSADM -o addsolution -filename C:\folder1\*.wsp

--Deploying solution package to http://<MACHINENAME>:<CENTRALPORT> site... STSADM -o deploysolution -name *.wsp -url http://<MACHINENAME>:<CENTRALPORT> - allowgacdeployment -immediate -force

--STOP timers if any
STSADM -o execadmsvcjobs

--Error adding WSP Package; attempting upgrade instead
STSADM -o upgradesolution -filename C:\folder1\*.wsp -immediate -allowgacdeployment -allowcaspolicies

--STOP timers if any
stsadm -o execadmsvcjobs

----Adding Template
stsadm -o addtemplate -filename C:\folder1\TEMPLATE1.stp -Title "<TEMPLATENAME>"

----Create SSP
STSADM -o createssp -title "<SSP Title>" -url <SSP URL With PORT> -mysiteurl <MySite URL With PORT> -ssplogin <Domain Name>\<User ID> -ssppassword <Password> -indexserver <SQL Server name> -indexlocation "C:\Program Files\Microsoft Office Servers\12.0\Data\Office Server\SSPIndexes" -sspdatabasename <SSP DB Name> -searchdatabasename <SSP DB Name>

----Starting Office SharePoint Server Search...
STSADM -o osearch -action start -f -role IndexQuery -farmcontactemail <User Email ID> -farmserviceaccount <Domain Name>\<User ID> -farmservicepassword <Password> -defaultindexlocation "C:\Program Files\Microsoft Office Servers\12.0\Data\Office Server\OSSIndex"

----Extending "site" to internet zone
STSADM -o extendvsinwebfarm -url <New site with Port> -vsname "<Existing site>"

----Configuring Forms Authentication for webapp...
STSADM -o authentication -url <Web app URL with Port> -type forms -membershipprovider FBA_AspNetSqlMembershipProvider -rolemanager FBA_AspNetSqlRoleProvider

Create custom STSADM command

How to create custom STSADM command?
1. Create one class that inherited from ISPStsadmCommand class, And implements below method spcified in the Interface

public string GetHelpMessage(string command)
{
//Your help message.
}

public int Run(string command, StringDictionary keyValues, out string output)
{
//Your custom code using SP object model.
//Set out parameter as out on command prompt.
}

2. Above created dll need to have strong name key.
3. Register the above dll in GAC.
4. Make custom stsadmcommands..xml and put in @ C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\CONFIG.

This file contents the below command.

<Commands>
<command
name="createlist"
class="<ClassName>, <NameSpace>, Version=<No>, Culture=neutral, PublicKeyToken=<Key>"/>
</Commands>

5. Try to run command from command prompt.

Thursday, September 10, 2009

How to Create Job Sceduler in Sharepoint?

How to Create Job Sceduler in Sharepoint?
Create one custom StsadmCommand using ISPStsadmCommand class. And implement Run method, this method will create/Schedule the job. This STSADM calls once while installing product. This will create jobscheduler.(Here scheduler calls every 50 min)

Example:

//This custom STSADM call once while installing product
public class CustomSTSADM : ISPStsadmCommand
{
public int Run(string command, StringDictionary keyValues, out string output)
{
CustomJob.CreateMyJob(URL);
}
}
// SPJobDefinition class
public class CustomJob_Class : SPJobDefinition
{
//Need to override
[SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)]
public override void Execute(Guid ContentDataBaseID)
{
//TODO: Write what should be done by this job every defined time.
}


//Create JobSchedule for 50 min
Public CustomJob(string Url)
{
SPSite mySite = new SPSite(Url);
SPWebApplication application = mySite.WebApplication;
SPJobDefinitionCollection jobsColl =
application.JobDefinitions;

CustomJob_Class customJob = new CustomJob_Class("CustomJob ",
application);

customJob.Title = " Custom Job ";

SPMinuteSchedule mySchedule = new SPMinuteSchedule();
mySchedule.BeginSecond = 0;
mySchedule.EndSecond = 59;
mySchedule.Interval = 50;
customJob.Schedule = mySchedule;

jobsColl.Add(customJob);
application.Update();
}
}

Saturday, August 22, 2009

How to create for Forms Authentication for SharePoint?

Create Database:
First step is to create membership database to save users and their credentials. To create membership database follow steps given below:
1. Open “%windir%\Microsoft.Net\Framework\vx.x.xxxxx” folder. Run aspnet_regsql.exe.
2. And complete the wizard steps(Select Configure SQL Server for application services option from the wizard).
3. Once wizard completed membership database has been created.

Configure Membership Providers:

This will allow us to add the users and roles into the database. To create user and role in database follow steps given below:
1. Create a new web site.
2. Add connection string in web.config file shown below

<connectionStrings>
<remove name="XX_ConnectionString" />
<add name="XX_ConnectionString"
connectionString="Integrated Security=SSPI;
Data Source=<SQLServerName>;Initial Catalog=<DatabaseName>;"
providerName="System.Data.SqlClient" />
</connectionStrings>

3. Now next specify the membership and role providers in the web.config file under <system.web> tag like shown below

<membership defaultProvider="XX_AspNetSqlMembershipProvider">
<providers>
<add connectionStringName="XX_ConnectionString"
passwordAttemptWindow="20"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
passwordStrengthRegularExpression=""
name="XX_AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider,System.Web,
Version = 2.0.0.0 ,
Culture = neutral,PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>

<roleManager enabled="true" defaultProvider="XX_AspNetSqlRoleProvider">
<providers>
<add connectionStringName="XX_ConnectionString"
applicationName="/"
name=”XX_AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider, System.Web,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>

4. Then used ASP.Net Configuration Wizard to create Role and Users.