Sunday, 16 June 2019

Forms Claims Authentication

 var formsAuthOption = SPFormsAuthenticationOption.None;
            var tokenType = SPSessionTokenWriteType.WriteSessionCookie;
             if (rememberme)
                 {
                     formsAuthOption = SPFormsAuthenticationOption.PersistentSignInRequest;
                    tokenType = SPSessionTokenWriteType.WritePersistentCookie;
                 }
    var settings = SPContext.Current.Site.WebApplication.IisSettings[SPContext.Current.Site.Zone];
             var authProvider = settings.FormsClaimsAuthenticationProvider;
             var securityToken = SPSecurityContext.SecurityTokenForFormsAuthentication(new Uri(SPContext.Current.Web.Url), authProvider.MembershipProvider,authProvider.RoleProvider, "test123",  "password", formsAuthOption);
             
  var fam = SPFederationAuthenticationModule.Current;
            fam.SetPrincipalAndWriteSessionToken(securityToken, tokenType);

Monday, 25 March 2019

Adding, Deploying, Uninstall and Update Solutions with PowerShell in SharePoint 2016

Adding, Deploying, Uninstall and Update Solutions with PowerShell in SharePoint

Add and deploy WSP
Add-SPSolution c:\code\SampleProject.wsp
Install-SPSolution –Identity SampleProject.wsp –WebApplication http://sp2016 -GACDeployment


To Update SPSolution
if soluiton is already deploy , then solution can be upgrade by following commands
Update-SPSolution –Identity SampleProject.wsp –LiteralPath c:\code\SampleProject.wsp –GACDeployment

To uninstall SPSolution or wsp

Uninstall-SPSolution –Identity SampleProject.wsp –WebApplication http://sp2016
Remove-SPSolution –Identity SampleProject.wsp

List of SharePoint PowerShell Commands

List of SharePoint 2013 PowerShell Commands

Add-SPAppDeniedEndpoint Add-SPClaimTypeMapping Add-SPDiagnosticsPerformanceCounter Add-SPDistributedCacheServiceInstanceOnLocalServer Add-SPEduClassMember Add-SPEduUser Add-SPInfoPathUserAgent Add-SPPluggableSecurityTrimmer Add-SPProfileLeader Add-SPProfileSyncConnection Add-SPRoutingMachineInfo Add-SPRoutingMachinePool Add-SPRoutingRule Add-SPScaleOutDatabase Add-SPServerScaleOutDatabase Add-SPServiceApplicationProxyGroupMember Add-SPShellAdmin Add-SPSiteSubscriptionFeaturePackMember Add-SPSiteSubscriptionProfileConfig Add-SPSocialAppPermissions Add-SPSolution Add-SPThrottlingRule Add-SPUserLicenseMapping Add-SPUserSolution Backup-SPConfigurationDatabase Backup-SPEnterpriseSearchServiceApplicationIndex Backup-SPFarm Backup-SPSite Clear-SPAppDeniedEndpoints Clear-SPBusinessDataCatalogEntityNotificationWeb Clear-SPDistributedCacheItem Clear-SPLogLevel Clear-SPMetadataWebServicePartitionData Clear-SPPerformancePointServiceApplicationTrustedLocation Clear-SPScaleOutDatabaseDeletedDataSubRange Clear-SPScaleOutDatabaseLog Clear-SPScaleOutDatabaseTenantData Clear-SPSecureStoreCredentialMapping Clear-SPSecureStoreDefaultProvider Clear-SPServerScaleOutDatabaseDeletedDataSubRange Clear-SPServerScaleOutDatabaseLog Clear-SPServerScaleOutDatabaseTenantData Clear-SPSiteSubscriptionBusinessDataCatalogConfig Connect-SPConfigurationDatabase Convert-SPWebApplication Copy-LocalActivitiesToWorkflowService Copy-SPAccessServicesDatabase Copy-SPBusinessDataCatalogAclToChildren Copy-SPSite Disable-SPAppAutoProvision Disable-SPBusinessDataCatalogEntity Disable-SPFeature Disable-SPHealthAnalysisRule Disable-SPInfoPathFormTemplate Disable-SPSessionStateService Disable-SPSingleSignOn Disable-SPTimerJob Disable-SPUserLicensing Disable-SPWebApplicationHttpThrottling Disconnect-SPConfigurationDatabase Dismount-SPContentDatabase Dismount-SPStateServiceDatabase Enable-SPAppAutoProvision Enable-SPBusinessDataCatalogEntity Enable-SPFeature Enable-SPHealthAnalysisRule Enable-SPInfoPathFormTemplate Enable-SPSessionStateService Enable-SPTimerJob Enable-SPUserLicensing Enable-SPWebApplicationHttpThrottling Export-SPAppPackage Export-SPBusinessDataCatalogModel Export-SPEnterpriseSearchTopology Export-SPInfoPathAdministrationFiles Export-SPMetadataWebServicePartitionData Export-SPPerformancePointContent Export-SPScaleOutDatabaseTenantData Export-SPServerScaleOutDatabaseTenantData Export-SPSiteSubscriptionBusinessDataCatalogConfig Export-SPSiteSubscriptionSettings Export-SPWeb Get-SPAccessServiceApplication Get-SPAccessServicesApplication Get-SPAccessServicesDatabase Get-SPAccessServicesDatabaseServer Get-SPAccessServicesDatabaseServerGroup Get-SPAccessServicesDatabaseServerGroupMapping Get-SPAlternateURL Get-SPAppAcquisitionSettings Get-SPAppAutoProvisionConnection Get-SPAppDeniedEndpoints Get-SPAppDisableSettings Get-SPAppDomain Get-SPAppHostingQuotas Get-SPAppInstance Get-SPAppMarketplaceSettings Get-SPAppPrincipal Get-SPAppScaleProfile Get-SPAppSiteSubscriptionName Get-SPAppStateSyncLastRunTime Get-SPAppStateUpdateInterval Get-SPAuthenticationProvider Get-SPAuthenticationRealm Get-SPBackupHistory Get-SPBingMapsBlockInAllLocales Get-SPBingMapsKey Get-SPBrowserCustomerExperienceImprovementProgram Get-SPBusinessDataCatalogEntityNotificationWeb Get-SPBusinessDataCatalogMetadataObject Get-SPBusinessDataCatalogThrottleConfig Get-SPCertificateAuthority Get-SPClaimProvider Get-SPClaimProviderManager Get-SPClaimTypeEncoding Get-SPContentDatabase Get-SPContentDeploymentJob Get-SPContentDeploymentPath Get-SPCustomLayoutsPage Get-SPDatabase Get-SPDataConnectionFile Get-SPDataConnectionFileDependent Get-SPDeletedSite Get-SPDesignerSettings Get-SPDiagnosticConfig Get-SPDiagnosticsPerformanceCounter Get-SPDiagnosticsProvider Get-SPDistributedCacheClientSetting Get-SPEduServiceSetting Get-SPEnterpriseSearchAdministrationComponent Get-SPEnterpriseSearchComponent Get-SPEnterpriseSearchContentEnrichmentConfiguration Get-SPEnterpriseSearchCrawlContentSource Get-SPEnterpriseSearchCrawlCustomConnector Get-SPEnterpriseSearchCrawlDatabase Get-SPEnterpriseSearchCrawlExtension Get-SPEnterpriseSearchCrawlLogReadPermission Get-SPEnterpriseSearchCrawlMapping Get-SPEnterpriseSearchCrawlRule Get-SPEnterpriseSearchFileFormat Get-SPEnterpriseSearchHostController Get-SPEnterpriseSearchLanguageResourcePhrase Get-SPEnterpriseSearchLinguisticComponentsStatus Get-SPEnterpriseSearchLinksDatabase Get-SPEnterpriseSearchMetadataCategory Get-SPEnterpriseSearchMetadataCrawledProperty Get-SPEnterpriseSearchMetadataManagedProperty Get-SPEnterpriseSearchMetadataMapping Get-SPEnterpriseSearchOwner Get-SPEnterpriseSearchPropertyRule Get-SPEnterpriseSearchPropertyRuleCollection Get-SPEnterpriseSearchQueryAndSiteSettingsService Get-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance Get-SPEnterpriseSearchQueryAndSiteSettingsServiceProxy Get-SPEnterpriseSearchQueryAuthority Get-SPEnterpriseSearchQueryDemoted Get-SPEnterpriseSearchQueryKeyword Get-SPEnterpriseSearchQueryScope Get-SPEnterpriseSearchQueryScopeRule Get-SPEnterpriseSearchQuerySpellingCorrection Get-SPEnterpriseSearchQuerySuggestionCandidates Get-SPEnterpriseSearchRankingModel Get-SPEnterpriseSearchResultItemType Get-SPEnterpriseSearchSecurityTrimmer Get-SPEnterpriseSearchService Get-SPEnterpriseSearchServiceApplication Get-SPEnterpriseSearchServiceApplicationBackupStore Get-SPEnterpriseSearchServiceApplicationProxy Get-SPEnterpriseSearchServiceInstance Get-SPEnterpriseSearchSiteHitRule Get-SPEnterpriseSearchStatus Get-SPEnterpriseSearchTopology Get-SPEnterpriseSearchVssDataPath Get-SPExcelBIServer Get-SPExcelBlockedFileType Get-SPExcelDataConnectionLibrary Get-SPExcelDataProvider Get-SPExcelFileLocation Get-SPExcelServiceApplication Get-SPExcelUserDefinedFunction Get-SPFarm Get-SPFarmConfig Get-SPFeature Get-SPHealthAnalysisRule Get-SPHelpCollection Get-SPInfoPathFormsService Get-SPInfoPathFormTemplate Get-SPInfoPathUserAgent Get-SPInfoPathWebServiceProxy Get-SPInternalAppStateSyncLastRunTime Get-SPInternalAppStateUpdateInterval Get-SPIRMSettings Get-SPLogEvent Get-SPLogLevel Get-SPManagedAccount Get-SPManagedPath Get-SPMetadataServiceApplication Get-SPMetadataServiceApplicationProxy Get-SPMobileMessagingAccount Get-SPODataConnectionSetting Get-SPODataConnectionSettingMetadata Get-SPOfficeStoreAppsDefaultActivation Get-SPPendingUpgradeActions Get-SPPerformancePointServiceApplication Get-SPPerformancePointServiceApplicationTrustedLocation Get-SPPluggableSecurityTrimmer Get-SPProcessAccount Get-SPProduct Get-SPProfileLeader Get-SPProfileServiceApplicationSecurity Get-SPRequestManagementSettings Get-SPRoutingMachineInfo Get-SPRoutingMachinePool Get-SPRoutingRule Get-SPScaleOutDatabase Get-SPScaleOutDatabaseDataState Get-SPScaleOutDatabaseInconsistency Get-SPScaleOutDatabaseLogEntry Get-SPSecureStoreApplication Get-SPSecureStoreSystemAccounts Get-SPSecurityTokenServiceConfig Get-SPServer Get-SPServerScaleOutDatabase Get-SPServerScaleOutDatabaseDataState Get-SPServerScaleOutDatabaseInconsistency Get-SPServerScaleOutDatabaseLogEntry Get-SPServiceApplication Get-SPServiceApplicationEndpoint Get-SPServiceApplicationPool Get-SPServiceApplicationProxy Get-SPServiceApplicationProxyGroup Get-SPServiceApplicationSecurity Get-SPServiceContext Get-SPServiceHostConfig Get-SPServiceInstance Get-SPSessionStateService Get-SPShellAdmin Get-SPSite Get-SPSiteAdministration Get-SPSiteSubscription Get-SPSiteSubscriptionConfig Get-SPSiteSubscriptionEdiscoveryHub Get-SPSiteSubscriptionEdiscoverySearchScope Get-SPSiteSubscriptionFeaturePack Get-SPSiteSubscriptionIRMConfig Get-SPSiteSubscriptionMetadataConfig Get-SPSiteUpgradeSessionInfo Get-SPSiteURL Get-SPSolution Get-SPStateServiceApplication Get-SPStateServiceApplicationProxy Get-SPStateServiceDatabase Get-SPTaxonomySession Get-SPThrottlingRule Get-SPTimerJob Get-SPTopologyServiceApplication Get-SPTopologyServiceApplicationProxy Get-SPTrustedIdentityTokenIssuer Get-SPTrustedRootAuthority Get-SPTrustedSecurityTokenIssuer Get-SPTrustedSecurityTokenService Get-SPTrustedServiceTokenIssuer Get-SPUpgradeActions Get-SPUsageApplication Get-SPUsageDefinition Get-SPUsageService Get-SPUser Get-SPUserLicense Get-SPUserLicenseMapping Get-SPUserLicensing Get-SPUserSettingsProvider Get-SPUserSettingsProviderManager Get-SPUserSolution Get-SPVisioExternalData Get-SPVisioPerformance Get-SPVisioSafeDataProvider Get-SPVisioServiceApplication Get-SPVisioServiceApplicationProxy Get-SPWeb Get-SPWebApplication Get-SPWebApplicationHttpThrottlingMonitor Get-SPWebPartPack Get-SPWebTemplate Get-SPWOPIBinding Get-SPWOPISuppressionSetting Get-SPWOPIZone Get-SPWorkflowConfig Get-TranslationThrottlingSettings Get-WorkflowServiceApplicationProxy Grant-SPBusinessDataCatalogMetadataObject Grant-SPObjectSecurity Import-SPAppPackage Import-SPBusinessDataCatalogDotNetAssembly Import-SPBusinessDataCatalogModel Import-SPEnterpriseSearchCustomExtractionDictionary Import-SPEnterpriseSearchPopularQueries Import-SPEnterpriseSearchThesaurus Import-SPEnterpriseSearchTopology Import-SPInfoPathAdministrationFiles Import-SPMetadataWebServicePartitionData Import-SPPerformancePointContent Import-SPScaleOutDatabaseTenantData Import-SPServerScaleOutDatabaseTenantData Import-SPSiteSubscriptionBusinessDataCatalogConfig Import-SPSiteSubscriptionSettings Import-SPWeb Initialize-SPResourceSecurity Initialize-SPStateServiceDatabase Install-SPApp Install-SPApplicationContent Install-SPDataConnectionFile Install-SPEduSites Install-SPFeature Install-SPHelpCollection Install-SPInfoPathFormTemplate Install-SPService Install-SPSolution Install-SPUserSolution Install-SPWebPartPack Merge-SPLogFile Mount-SPContentDatabase Mount-SPStateServiceDatabase Move-SPBlobStorageLocation Move-SPDeletedSite Move-SPProfileManagedMetadataProperty Move-SPSite Move-SPSocialComments Move-SPUser New-SPAccessServiceApplication New-SPAccessServicesApplication New-SPAccessServicesApplicationProxy New-SPAccessServicesDatabaseServer New-SPAlternateURL New-SPAppManagementServiceApplication New-SPAppManagementServiceApplicationProxy New-SPAuthenticationProvider New-SPAzureAccessControlServiceApplicationProxy New-SPBECWebServiceApplicationProxy New-SPBusinessDataCatalogServiceApplication New-SPBusinessDataCatalogServiceApplicationProxy New-SPCentralAdministration New-SPClaimProvider New-SPClaimsPrincipal New-SPClaimTypeEncoding New-SPClaimTypeMapping New-SPConfigurationDatabase New-SPContentDatabase New-SPContentDeploymentJob New-SPContentDeploymentPath New-SPEduClass New-SPEnterpriseSearchAdminComponent New-SPEnterpriseSearchAnalyticsProcessingComponent New-SPEnterpriseSearchContentEnrichmentConfiguration New-SPEnterpriseSearchContentProcessingComponent New-SPEnterpriseSearchCrawlComponent New-SPEnterpriseSearchCrawlContentSource New-SPEnterpriseSearchCrawlCustomConnector New-SPEnterpriseSearchCrawlDatabase New-SPEnterpriseSearchCrawlExtension New-SPEnterpriseSearchCrawlMapping New-SPEnterpriseSearchCrawlRule New-SPEnterpriseSearchFileFormat New-SPEnterpriseSearchIndexComponent New-SPEnterpriseSearchLanguageResourcePhrase New-SPEnterpriseSearchLinksDatabase New-SPEnterpriseSearchMetadataCategory New-SPEnterpriseSearchMetadataCrawledProperty New-SPEnterpriseSearchMetadataManagedProperty New-SPEnterpriseSearchMetadataMapping New-SPEnterpriseSearchQueryAuthority New-SPEnterpriseSearchQueryDemoted New-SPEnterpriseSearchQueryKeyword New-SPEnterpriseSearchQueryProcessingComponent New-SPEnterpriseSearchQueryScope New-SPEnterpriseSearchQueryScopeRule New-SPEnterpriseSearchRankingModel New-SPEnterpriseSearchResultItemType New-SPEnterpriseSearchSecurityTrimmer New-SPEnterpriseSearchServiceApplication New-SPEnterpriseSearchServiceApplicationProxy New-SPEnterpriseSearchSiteHitRule New-SPEnterpriseSearchTopology New-SPExcelBIServer New-SPExcelBlockedFileType New-SPExcelDataConnectionLibrary New-SPExcelDataProvider New-SPExcelFileLocation New-SPExcelServiceApplication New-SPExcelUserDefinedFunction New-SPLogFile New-SPManagedAccount New-SPManagedPath New-SPMarketplaceWebServiceApplicationProxy New-SPMetadataServiceApplication New-SPMetadataServiceApplicationProxy New-SPODataConnectionSetting New-SPPerformancePointServiceApplication New-SPPerformancePointServiceApplicationProxy New-SPPerformancePointServiceApplicationTrustedLocation New-SPPowerPointConversionServiceApplication New-SPPowerPointConversionServiceApplicationProxy New-SPProfileServiceApplication New-SPProfileServiceApplicationProxy New-SPRequestManagementRuleCriteria New-SPSecureStoreApplication New-SPSecureStoreApplicationField New-SPSecureStoreServiceApplication New-SPSecureStoreServiceApplicationProxy New-SPSecureStoreTargetApplication New-SPServiceApplicationPool New-SPServiceApplicationProxyGroup New-SPSite New-SPSiteSubscription New-SPSiteSubscriptionFeaturePack New-SPStateServiceApplication New-SPStateServiceApplicationProxy New-SPStateServiceDatabase New-SPSubscriptionSettingsServiceApplication New-SPSubscriptionSettingsServiceApplicationProxy New-SPTranslationServiceApplication New-SPTranslationServiceApplicationProxy New-SPTrustedIdentityTokenIssuer New-SPTrustedRootAuthority New-SPTrustedSecurityTokenIssuer New-SPTrustedSecurityTokenService New-SPTrustedServiceTokenIssuer New-SPUsageApplication New-SPUsageLogFile New-SPUser New-SPUserLicenseMapping New-SPUserSettingsProvider New-SPVisioSafeDataProvider New-SPVisioServiceApplication New-SPVisioServiceApplicationProxy New-SPWeb New-SPWebApplication New-SPWebApplicationExtension New-SPWOPIBinding New-SPWOPISuppressionSetting New-SPWordConversionServiceApplication New-SPWorkManagementServiceApplication New-SPWorkManagementServiceApplicationProxy New-WorkflowServiceApplicationProxy Publish-SPServiceApplication Receive-SPServiceApplicationConnectionInfo Register-SPAppPrincipal Register-SPWorkflowService Remove-SPAccessServicesDatabaseServer Remove-SPActivityFeedItems Remove-SPAlternateURL Remove-SPAppDeniedEndpoint Remove-SPAppPrincipalPermission Remove-SPBusinessDataCatalogModel Remove-SPClaimProvider Remove-SPClaimTypeMapping Remove-SPConfigurationDatabase Remove-SPContentDatabase Remove-SPContentDeploymentJob Remove-SPContentDeploymentPath Remove-SPDeletedSite Remove-SPDiagnosticsPerformanceCounter Remove-SPDistributedCacheServiceInstanceOnLocalServer Remove-SPEduClassMember Remove-SPEnterpriseSearchComponent Remove-SPEnterpriseSearchContentEnrichmentConfiguration Remove-SPEnterpriseSearchCrawlContentSource Remove-SPEnterpriseSearchCrawlCustomConnector Remove-SPEnterpriseSearchCrawlDatabase Remove-SPEnterpriseSearchCrawlExtension Remove-SPEnterpriseSearchCrawlLogReadPermission Remove-SPEnterpriseSearchCrawlMapping Remove-SPEnterpriseSearchCrawlRule Remove-SPEnterpriseSearchFileFormat Remove-SPEnterpriseSearchLanguageResourcePhrase Remove-SPEnterpriseSearchLinksDatabase Remove-SPEnterpriseSearchMetadataCategory Remove-SPEnterpriseSearchMetadataManagedProperty Remove-SPEnterpriseSearchMetadataMapping Remove-SPEnterpriseSearchQueryAuthority Remove-SPEnterpriseSearchQueryDemoted Remove-SPEnterpriseSearchQueryKeyword Remove-SPEnterpriseSearchQueryScope Remove-SPEnterpriseSearchQueryScopeRule Remove-SPEnterpriseSearchRankingModel Remove-SPEnterpriseSearchResultItemType Remove-SPEnterpriseSearchSecurityTrimmer Remove-SPEnterpriseSearchServiceApplication Remove-SPEnterpriseSearchServiceApplicationProxy Remove-SPEnterpriseSearchServiceApplicationSiteSettings Remove-SPEnterpriseSearchSiteHitRule Remove-SPEnterpriseSearchTenantConfiguration Remove-SPEnterpriseSearchTenantSchema Remove-SPEnterpriseSearchTopology Remove-SPExcelBIServer Remove-SPExcelBlockedFileType Remove-SPExcelDataConnectionLibrary Remove-SPExcelDataProvider Remove-SPExcelFileLocation Remove-SPExcelUserDefinedFunction Remove-SPInfoPathUserAgent Remove-SPManagedAccount Remove-SPManagedPath Remove-SPODataConnectionSetting Remove-SPPerformancePointServiceApplication Remove-SPPerformancePointServiceApplicationProxy Remove-SPPerformancePointServiceApplicationTrustedLocation Remove-SPPluggableSecurityTrimmer Remove-SPProfileLeader Remove-SPProfileSyncConnection Remove-SPRoutingMachineInfo Remove-SPRoutingMachinePool Remove-SPRoutingRule Remove-SPScaleOutDatabase Remove-SPSecureStoreApplication Remove-SPServerScaleOutDatabase Remove-SPServiceApplication Remove-SPServiceApplicationPool Remove-SPServiceApplicationProxy Remove-SPServiceApplicationProxyGroup Remove-SPServiceApplicationProxyGroupMember Remove-SPShellAdmin Remove-SPSite Remove-SPSiteSubscription Remove-SPSiteSubscriptionBusinessDataCatalogConfig Remove-SPSiteSubscriptionFeaturePack Remove-SPSiteSubscriptionFeaturePackMember Remove-SPSiteSubscriptionMetadataConfig Remove-SPSiteSubscriptionProfileConfig Remove-SPSiteSubscriptionSettings Remove-SPSiteUpgradeSessionInfo Remove-SPSiteURL Remove-SPSocialAppPermissions Remove-SPSocialItemByDate Remove-SPSolution Remove-SPSolutionDeploymentLock Remove-SPStateServiceDatabase Remove-SPThrottlingRule Remove-SPTranslationServiceJobHistory Remove-SPTrustedIdentityTokenIssuer Remove-SPTrustedRootAuthority Remove-SPTrustedSecurityTokenIssuer Remove-SPTrustedSecurityTokenService Remove-SPTrustedServiceTokenIssuer Remove-SPUsageApplication Remove-SPUser Remove-SPUserLicenseMapping Remove-SPUserSettingsProvider Remove-SPUserSolution Remove-SPVisioSafeDataProvider Remove-SPWeb Remove-SPWebApplication Remove-SPWOPIBinding Remove-SPWOPISuppressionSetting Remove-SPWordConversionServiceJobHistory Rename-SPServer Repair-SPManagedAccountDeployment Repair-SPSite Repartition-SPEnterpriseSearchLinksDatabases Request-SPUpgradeEvaluationSite Reset-SPAccessServicesDatabasePassword Restart-SPAppInstanceJobs Restore-SPDeletedSite Restore-SPEnterpriseSearchServiceApplication Restore-SPEnterpriseSearchServiceApplicationIndex Restore-SPFarm Restore-SPSite Resume-SPEnterpriseSearchServiceApplication Resume-SPStateServiceDatabase Revoke-SPBusinessDataCatalogMetadataObject Revoke-SPObjectSecurity Set-SPAccessServiceApplication Set-SPAccessServicesApplication Set-SPAccessServicesDatabaseServer Set-SPAccessServicesDatabaseServerGroupMapping Set-SPAlternateURL Set-SPAppAcquisitionSettings Set-SPAppAutoProvisionConnection Set-SPAppDisableSettings Set-SPAppDomain Set-SPAppHostingQuotas Set-SPAppManagementDeploymentId Set-SPAppMarketplaceSettings Set-SPAppPrincipalPermission Set-SPAppScaleProfile Set-SPAppSiteSubscriptionName Set-SPAppStateUpdateInterval Set-SPAuthenticationRealm Set-SPBingMapsBlockInAllLocales Set-SPBingMapsKey Set-SPBrowserCustomerExperienceImprovementProgram Set-SPBusinessDataCatalogEntityNotificationWeb Set-SPBusinessDataCatalogMetadataObject Set-SPBusinessDataCatalogServiceApplication Set-SPBusinessDataCatalogThrottleConfig Set-SPCentralAdministration Set-SPClaimProvider Set-SPContentDatabase Set-SPContentDeploymentJob Set-SPContentDeploymentPath Set-SPCustomLayoutsPage Set-SPDataConnectionFile Set-SPDesignerSettings Set-SPDiagnosticConfig Set-SPDiagnosticsProvider Set-SPDistributedCacheClientSetting Set-SPEduServiceSetting Set-SPEnterpriseSearchAdministrationComponent Set-SPEnterpriseSearchContentEnrichmentConfiguration Set-SPEnterpriseSearchCrawlContentSource Set-SPEnterpriseSearchCrawlDatabase Set-SPEnterpriseSearchCrawlLogReadPermission Set-SPEnterpriseSearchCrawlRule Set-SPEnterpriseSearchLinguisticComponentsStatus Set-SPEnterpriseSearchLinksDatabase Set-SPEnterpriseSearchMetadataCategory Set-SPEnterpriseSearchMetadataCrawledProperty Set-SPEnterpriseSearchMetadataManagedProperty Set-SPEnterpriseSearchMetadataMapping Set-SPEnterpriseSearchPrimaryHostController Set-SPEnterpriseSearchQueryAuthority Set-SPEnterpriseSearchQueryKeyword Set-SPEnterpriseSearchQueryScope Set-SPEnterpriseSearchQueryScopeRule Set-SPEnterpriseSearchQuerySpellingCorrection Set-SPEnterpriseSearchRankingModel Set-SPEnterpriseSearchResultItemType Set-SPEnterpriseSearchService Set-SPEnterpriseSearchServiceApplication Set-SPEnterpriseSearchServiceApplicationProxy Set-SPEnterpriseSearchServiceInstance Set-SPEnterpriseSearchTopology Set-SPExcelBIServer Set-SPExcelDataConnectionLibrary Set-SPExcelDataProvider Set-SPExcelFileLocation Set-SPExcelServiceApplication Set-SPExcelUserDefinedFunction Set-SPFarmConfig Set-SPInfoPathFormsService Set-SPInfoPathFormTemplate Set-SPInfoPathWebServiceProxy Set-SPInternalAppStateUpdateInterval Set-SPIRMSettings Set-SPLogLevel Set-SPManagedAccount Set-SPMetadataServiceApplication Set-SPMetadataServiceApplicationProxy Set-SPMobileMessagingAccount Set-SPODataConnectionSetting Set-SPODataConnectionSettingMetadata Set-SPOfficeStoreAppsDefaultActivation Set-SPPassPhrase Set-SPPerformancePointSecureDataValues Set-SPPerformancePointServiceApplication Set-SPPowerPointConversionServiceApplication Set-SPProfileServiceApplication Set-SPProfileServiceApplicationProxy Set-SPProfileServiceApplicationSecurity Set-SPRequestManagementSettings Set-SPRoutingMachineInfo Set-SPRoutingMachinePool Set-SPRoutingRule Set-SPScaleOutDatabaseDataRange Set-SPScaleOutDatabaseDataSubRange Set-SPSecureStoreApplication Set-SPSecureStoreDefaultProvider Set-SPSecureStoreServiceApplication Set-SPSecureStoreSystemAccounts Set-SPSecurityTokenServiceConfig Set-SPServerScaleOutDatabaseDataRange Set-SPServerScaleOutDatabaseDataSubRange Set-SPServiceApplication Set-SPServiceApplicationEndpoint Set-SPServiceApplicationPool Set-SPServiceApplicationSecurity Set-SPServiceHostConfig Set-SPSessionStateService Set-SPSite Set-SPSiteAdministration Set-SPSiteSubscriptionConfig Set-SPSiteSubscriptionEdiscoveryHub Set-SPSiteSubscriptionIRMConfig Set-SPSiteSubscriptionMetadataConfig Set-SPSiteSubscriptionProfileConfig Set-SPSiteURL Set-SPStateServiceApplication Set-SPStateServiceApplicationProxy Set-SPStateServiceDatabase Set-SPSubscriptionSettingsServiceApplication Set-SPThrottlingRule Set-SPTimerJob Set-SPTopologyServiceApplication Set-SPTopologyServiceApplicationProxy Set-SPTranslationServiceApplication Set-SPTranslationServiceApplicationProxy Set-SPTrustedIdentityTokenIssuer Set-SPTrustedRootAuthority Set-SPTrustedSecurityTokenIssuer Set-SPTrustedSecurityTokenService Set-SPTrustedServiceTokenIssuer Set-SPUsageApplication Set-SPUsageDefinition Set-SPUsageService Set-SPUser Set-SPVisioExternalData Set-SPVisioPerformance Set-SPVisioSafeDataProvider Set-SPVisioServiceApplication Set-SPWeb Set-SPWebApplication Set-SPWebApplicationHttpThrottlingMonitor Set-SPWOPIBinding Set-SPWOPIZone Set-SPWordConversionServiceApplication Set-SPWorkflowConfig Set-SPWorkManagementServiceApplication Set-SPWorkManagementServiceApplicationProxy Set-TranslationThrottlingSettings Split-SPScaleOutDatabase Split-SPServerScaleOutDatabase Start-SPAdminJob Start-SPAssignment Start-SPContentDeploymentJob Start-SPDiagnosticsSession Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance Start-SPEnterpriseSearchServiceInstance Start-SPInfoPathFormTemplate Start-SPServiceInstance Start-SPTimerJob Stop-SPAssignment Stop-SPDiagnosticsSession Stop-SPDistributedCacheServiceInstanceGracefullyOnLocalServer Stop-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance Stop-SPEnterpriseSearchServiceInstance Stop-SPInfoPathFormTemplate Stop-SPServiceInstance Suspend-SPEnterpriseSearchServiceApplication Suspend-SPStateServiceDatabase Test-SPContentDatabase Test-SPInfoPathFormTemplate Test-SPSite Uninstall-SPAppInstance Uninstall-SPDataConnectionFile Uninstall-SPFeature Uninstall-SPHelpCollection Uninstall-SPInfoPathFormTemplate Uninstall-SPSolution Uninstall-SPUserSolution Uninstall-SPWebPartPack Unpublish-SPServiceApplication Update-SPAppCatalogSettings Update-SPAppInstance Update-SPFarmEncryptionKey Update-SPInfoPathAdminFileUrl Update-SPInfoPathFormTemplate Update-SPInfoPathUserFileUrl Update-SPProfilePhotoStore Update-SPRepopulateMicroblogFeedCache Update-SPRepopulateMicroblogLMTCache Update-SPSecureStoreApplicationServerKey Update-SPSecureStoreCredentialMapping Update-SPSecureStoreGroupCredentialMapping Update-SPSecureStoreMasterKey Update-SPSolution Update-SPUserSolution Update-SPWOPIProofKey Upgrade-SPContentDatabase Upgrade-SPEnterpriseSearchServiceApplication Upgrade-SPEnterpriseSearchServiceApplicationSiteSettings Upgrade-SPFarm Upgrade-SPSingleSignOnDatabase Upgrade-SPSite

Wednesday, 19 June 2013

Twitter API Authentication -- OAuth v 1.1

You can use following class to get the Tweets from from Twitter API v 1.1 using the oAuth.  you should perform following steps.

 Step1:

Login your Developer account on twitter website by using following link.

https://dev.twitter.com/user/login

Step2:

Click on the My Applications on the user profile as shown in following pic.

 



Step3:

Click on the Create New Application button. Fill the form and save the information as shown in following figure

 



Step4:

It will display the list of your created applications as shown in following figure.. so select your application so select your application , it will show the consumer key and consumer secret as shown in following figure.




Step5:

 Use following code to get tweets.

Twitter OAuth is based on four tokens generally referred to as consumer key and consumer secret



public class ManageTweets
    {
        public string OAuthConsumerKey { get; set; }
        public string OAuthConsumerSecret { get; set; }
        public string OAuthUrl { get; set; }
                     
        public DataTable GetTweetsListFromTwitter()
        {

            DataTable dataTable =TweetsDataTable();
            var timeLineJson = string.Empty;
            var oAuthConsumerKey = OAuthConsumerKey;
            var oAuthConsumerSecret = OAuthConsumerSecret;
            var oAuthUrl = OAuthUrl;
           
          
            //var screenname = "yourscreenname";
            // Do the Authenticate
            var authHeaderFormat = "Basic {0}";

            var authHeader = string.Format(authHeaderFormat,
                 Convert.ToBase64String(Encoding.UTF8.GetBytes(Uri.EscapeDataString(oAuthConsumerKey) + ":" +
                        Uri.EscapeDataString((oAuthConsumerSecret)))
                        ));

            var postBody = "grant_type=client_credentials";

            System.Net.HttpWebRequest authRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(oAuthUrl);
                        authRequest.Headers.Add("Authorization", authHeader);
            authRequest.Method = "POST";
            authRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
            authRequest.AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate;

            using (System.IO.Stream stream = authRequest.GetRequestStream())
            {
                byte[] content = ASCIIEncoding.ASCII.GetBytes(postBody);
                stream.Write(content, 0, content.Length);
            }

            authRequest.Headers.Add("Accept-Encoding", "gzip");

            System.Net.WebResponse authResponse = authRequest.GetResponse();
            // // deserialize into an object
            TwitAuthenticateResponse twitAuthResponse;
            using (authResponse)
            {
                using (var reader = new System.IO.StreamReader(authResponse.GetResponseStream()))
                {
                    var objectText = reader.ReadToEnd();
                    //objectText = objectText.Replace("{\"","");
                    //string[] arr = objectText.Split(':');
                    System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
                    twitAuthResponse = js.Deserialize<TwitAuthenticateResponse>(objectText);
                }
            }

            // Do the timeline
            var timelineFormat = "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name={0}&include_rts=1&exclude_replies=1&count=5";
            timelineUrl = string.Format(timelineFormat, screenname);

          

            System.Net.HttpWebRequest timeLineRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(
timelineUrl );
            if (!string.IsNullOrEmpty(ProxyURL))
            {
                timeLineRequest.Proxy = webproxy;
            }
            var timelineHeaderFormat = "{0} {1}";
            timeLineRequest.Headers.Add("Authorization", string.Format(timelineHeaderFormat, twitAuthResponse.token_type, twitAuthResponse.access_token));
            timeLineRequest.Method = "Get";
            System.Net.WebResponse timeLineResponse = timeLineRequest.GetResponse();

            using (authResponse)
            {
                using (var reader = new System.IO.StreamReader(timeLineResponse.GetResponseStream()))
                {
                    timeLineJson = reader.ReadToEnd();
                }

                Newtonsoft.Json.Linq.JArray jsonDat = Newtonsoft.Json.Linq.JArray.Parse(timeLineJson);

                for (int x = 0; x < jsonDat.Count(); x++)
                {
                    Newtonsoft.Json.Linq.JObject tweet = Newtonsoft.Json.Linq.JObject.Parse(jsonDat[x].ToString());
                    string created_at = tweet["created_at"].ToString();
                    string tweettext = tweet["text"].ToString();
                    string profile_image_url_https = tweet["user"]["profile_image_url_https"].ToString() ;
                    dataTable.Rows.Add(tweettext.Replace("\"", ""), profile_image_url_https.Replace("\"", ""), created_at.Replace("\"", ""));
                    //whatever else you want to look up
                }

            }
            return dataTable;
        }
      
        private DataTable TweetsDataTable()
        {
            DataTable tweetsTable = new DataTable();
            tweetsTable.Columns.Add("Tweet_Text", typeof(string));
            tweetsTable.Columns.Add("Department_Logo", typeof(string));
            tweetsTable.Columns.Add("createdAt", typeof(string));
            return tweetsTable;
        }

        public class TwitAuthenticateResponse
        {
            public string token_type { get; set; }
            public string access_token { get; set; }
        }
    }





 

Friday, 19 October 2012

enable versioning to sharepoint list


The following is the code snippet which is used to do the versioning settings.
        ///Enable Versioning to lists
        SPContext.Current.Web.AllowUnsafeUpdates = true;
        SPList objList = SPContext.Current.Web.Lists["TestList"];

        //EnableVersioning:- True if versioning is enabled for the document library; Otherwise false.
        objList.EnableVersioning = true;
        //EnableMinorVersions:- true if minor versions are enabled when versioning is enabled for the document library; otherwise false.
        objList.EnableMinorVersions = true;
        //EnableModeration: property is true if Content Approval is enabled; otherwise, false
        objList.EnableModeration = true;
        //ForceCheckout:- This property is true if Forced checkout is enabled for the document library; otherwise false
        objList.ForceCheckout = true;
        //DraftVersionVisibility:- Set the accessibilty of the minor versions of document drafts within the list.
        objList.DraftVersionVisibility = DraftVisibilityType.Author;
        objList.Update();
  SPContext.Current.Web.AllowUnsafeUpdates = false;
       

Sunday, 27 March 2011

Retriving SharePoint WSP Files from Config DB using SharePoint Object Model

WSP files are the preferred way of deploying the new functionlaity in SharePoint. WSP files are stored in the Config DB. If you need to extract these files you can do that by using the SharePoint Object Model Code. The following code snippet will retrive all the solutions from the config DB and will place them in the specified location:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace Retrive_Solutions
{ 
    class SolutionBackup
    {
        static void Main(string[] args)
        {
            SPSolutionCollection AllSolutions = SPFarm.Local.Solutions;
            foreach (SPSolution Solution in AllSolutions)
            {
                SPPersistedFile wspFile = Solution.SolutionFile;
                wspFile.SaveAs("C:\\Solutions\\" + Solution.Name);
            }
        }
    }
}