I'm deploying my web parts using the sharepoint solution mechanism. Untul now, everything worked fine, but when i added CAS policies to the manifest.xml file, the deployment doesn't work as it should.
When deploying the solution with the CAS policies, there are no errors, but the policy file isn't created, the dll isn't copied, and the SafeControls entries aren't added to the web.config. My manifest.xml file looks like this :
<Solution SolutionId="{8099F953-02F2-49e1-B620-06B9050515A3}"
xmlns="http://schemas.microsoft.com/sharepoint/">
<FeatureManifests>
<FeatureManifest Location="Przydzialy\feature.xml" />
</FeatureManifests>
<TemplateFiles>
<TemplateFile Location="FEATURES\Przydzialy\AjaxWebPart.dwp" />
<TemplateFile Location="FEATURES\Przydzialy\UserControlContainer.dwp" />
</TemplateFiles>
<Assemblies>
<Assembly DeploymentTarget="WebApplication" Location="Package.WebParts.dll">
<SafeControls>
<SafeControl Assembly="Package.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9a8b1f3d028b8494" Namespace="Package.WebParts" TypeName="UserControlContainer" Safe="True" />
<SafeControl Assembly="Package.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9a8b1f3d028b8494" Namespace="Package.WebParts" TypeName="AjaxWebPart" Safe="True" />
<SafeControl Assembly="Package.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9a8b1f3d028b8494" Namespace="Package.WebParts" TypeName="ProgressTemplate" Safe="True" />
<SafeControl Assembly="Package.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9a8b1f3d028b8494" Namespace="Package.WebParts.SmartWebPart" TypeName="UserControlContainerToolPart" Safe="True" />
</SafeControls>
</Assembly>
</Assemblies>
<CodeAccessSecurity>
<PolicyItem>
<PermissionSet class="NamedPermissionSet" version="1" Description="Permission set for Package.WebParts">
<IPermission class="AspNetHostingPermission" version="1" Level="Medium" />
</PermissionSet>
<Assemblies>
<Assembly Name="Package.WebParts" />
</Assemblies>
</PolicyItem>
</CodeAccessSecurity>
</Solution>
Did anybody had a problem like that befor ? I've run out of ideas at this point, so I'm open for suggestions.
Check your web.config and make sure that the trust level is not set to full. It should be set to WSS_Minimal if you haven't deployed any CAS policies yet or WSS_Custom if you have already deployed something. Make sure that you don't have any readonly files in your solution package as that causes problems.
Lastly, are you deploying your solution via Central Admin or stsadm? If you are deploying via stsadm, then go to central admin and see if there are any errors shown when you deploy your solution.
More than likely you are going to need more permissionSets as well, check my post here for more on Code Access Security.
Related
I have a Windows Azure Website (built with ASP.NET Web Pages), and in the configuration have enabled "Application Diagnostics" for both Blob storage and file storage:
I've then added some Trace statements to a Razor page to test it out
#{
System.Diagnostics.Trace.TraceInformation("INFORMATION");
System.Diagnostics.Trace.TraceWarning("WARNING");
System.Diagnostics.Trace.TraceError("ERROR");
}
However, this results in no logs at all, either in the file system or the blob.
For good measure I attempted to add various settings to my web.config file (shown below), although from the documentation I read, it doesn't seem as though this should be necessary. But it makes no difference - I still see no diagnostic logs in the file system or the blob.
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<trace enabled="true"/>
<httpRuntime targetFramework="4.5" />
</system.web>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
</add>
<add name="WebPageTraceListener"
type="System.Web.WebPageTraceListener, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</listeners>
</trace>
</system.diagnostics>
Is there anything else I need to configure that I've missed? Could it be that this simply doesn't work at all for ASP.NET Web Pages projects?
To enable tracing from a razor page add the following to your web.config:
<system.codedom>
<compilers>
<compiler
language="c#;cs;csharp"
extension=".cs"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
compilerOptions="/define:TRACE"
warningLevel="1" />
</compilers>
</system.codedom>
Source: http://blogs.msdn.com/b/webdev/archive/2013/07/16/tracing-in-asp-net-mvc-razor-views.aspx
Note that tracing from your cs files should work without any changes to web.config.
I have a class library package that needs to merge the following to the existing web/app.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="MyCompany.MyLibrary" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<MyCompany.MyLibrary.Settings>
<setting name="Environment" serializeAs="String">
<value></value>
</setting>
</MyCompany.MyLibrary.Settings>
</applicationSettings>
</configuration>
I did this using .transform files and it installs fine.
The user (using NuGet 2.8.3 and VS 2012) is able to easily edit the value in "Environment" to properly configure the library.
However, when I release the next version, the user runs into a problem when they use NuGet to update their solution.
The update clears out their existing "Environment" value in the user's config files.
I tried using an .install.xdt file and do:
<setting name="Environment" serializeAs="String" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)">
That didn't work either. Is there a way to tell NuGet to ignore the value under "Environment" if it's already there so it doesn't clear out existing values?
I don't want to apply that ignore logic to all of MyCompany.MyLibrary.Settings in case a future update adds or removes a new setting.
I have a web site that uses ASPNETDB for membership/roles/profiles. The web site has some administration pages and I want to add a couple of new pages to be able to add/edit/delete users for the web site.
I have two different connection strings for the database, with different permissions/levels of security.
I want one ("ASPNETDBConnection") to be used solely for the web site login process, and other general use purposes for all visitors.
I want the other ("ASPNETDBConnectionAdmin") to be used for the add/edit/delete pages for logged in users.
I do not want to create a virtual directory/application (cannot - don't ask!).
I gather that while I can have only one profile, I can have multiple providers...
The following is taken from my current web.config file:
<system.web>
<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" connectionStringName="ASPNETDBConnection" applicationName="MyWebSite" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
<add name="AspNetSqlMembershipProviderAdmin" connectionStringName="ASPNETDBConnectionAdmin" applicationName="MyWebSite" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<profile defaultProvider="AspNetSqlProfileProvider" enabled="true">
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" connectionStringName="ASPNETDBConnection" applicationName="MyWebSite" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="AspNetSqlProfileProviderAdmin" connectionStringName="ASPNETDBConnectionAdmin" applicationName="MyWebSite" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</profile>
<roleManager defaultProvider="AspNetSqlRoleProvider" enabled="true">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" connectionStringName="ASPNETDBConnection" applicationName="MyWebSite" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="AspNetSqlRoleProviderAdmin" connectionStringName="ASPNETDBConnectionAdmin" applicationName="MyWebSite" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
</system.web>
My question is, how do I switch providers?
How do I change the membership provider from the default "AspNetSqlMembershipProvider" to the alternative one, "AspNetSqlMembershipProviderAdmin" (dynamically?) in the code for the add/edit/user pages?
Et al for role & profile providers.
Any help in VB, rather than C# please.
Many Thanks...
Crimblepud
Crimblepud
I tried to search, on it and even i tried making custom profiler,but not getting the idea, in between i found some useful resources,check it on
Code Project on Profile
Profile Mechanism
I'm looking for a way to automate the deployment of a custom CAS policy in SharePoint.
What i would like to achieve is the following:
All assemblies that have been built and signed by our build server (with a secret key) should run in SharePoint under the 'higher than normal' trust level.
Now I can manually edit the cas policy files to include something like this:
<CodeGroup class="UnionCodeGroup" version="1" PermissionSetName="MyPermissionSet" Name="[My Company public key]" Description="Grants all ">
<IMembershipCondition class="StrongNameMembershipCondition" version="1" PublicKeyBlob="[public key goes here]" />
</CodeGroup>
And that works great. However, we have several huge sharepoint farms, with many applications running on it. I'd like to avoid having to manually edit all policy files to include this xml snippet.
Is there a way to automate this? For example, from a feature?
With kind regards,
Erwin van der Valk
Hope you're familiar with .wsp files. This is a standard way to deploying anything to the farm. You can also deploy CAS policy entries though a wsp file. (Maybe you'll want to create a wsp file just for your cas policy). wsp files are the same as cab files, just renamed. Inside a wsp file lives manifest.xml in which you can define what changes to the CAS file you want to apply. The great thing about doing it this way that its reversible by uninstallaing the WSP. I've seen several different approaches to deploying CAS policies including having your custom policy file as part of your wsp and it gets deployed just like any other file.
You should google wsp cas policy manifest.xml for further tutorials.
Hope this helps..
This is what I have done to automate the deployment of CAS policies of my WebPart:
Inside my .wsp file, I have a Manifest.xml file with this content:
<?xml version="1.0" encoding="utf-8" ?>
<Solution SolutionId="0C006FE3-919D-4a2a-9CF0-FEA66A0A91E4" xmlns="http://schemas.microsoft.com/sharepoint/" >
<Assemblies>
<Assembly Location="MyWebPart.dll" DeploymentTarget="WebApplication">
<ClassResources>
<ClassResource Location="MyWebpart_log.config" />
<ClassResource Location="combo.css" />
<ClassResource Location="combo.js" />
<ClassResource Location="img/arrow.png" />
<ClassResource Location="img/coordination.gif" />
<ClassResource Location="img/dt-arrow-dn.png" />
<ClassResource Location="img/dt-arrow-up.png" />
<ClassResource Location="img/loading.gif" />
<ClassResource Location="img/menu-button-arrow.png" />
<ClassResource Location="img/spinner.gif" />
<ClassResource Location="img/split-button-arrow.png" />
<ClassResource Location="img/sprite.png" />
</ClassResources>
<SafeControls>
<SafeControl Assembly="MyWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=017e953639e07a31"
Namespace="MyWebPart" TypeName="*" Safe="True" />
</SafeControls>
</Assembly>
<Assembly Location="log4net.dll" DeploymentTarget="WebApplication">
<SafeControls>
<SafeControl Assembly="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821"
Namespace="MyWebPart" TypeName="*" Safe="True" />
</SafeControls>
</Assembly>
</Assemblies>
<CodeAccessSecurity>
<PolicyItem>
<PermissionSet class="NamedPermissionSet" version="1" Name="MyWebPartPermissionSet"
Description="Permission set for My Web Part">
<IPermission class="AspNetHostingPermission" version="1" Level="Medium" />
<IPermission class="System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1" Unrestricted="true" />
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1" Read="$AppDir$" Write="$AppDir$" Append="$AppDir$" PathDiscovery="$AppDir$" />
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Execution" />
<IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" ObjectModel="True" />
<IPermission class="Microsoft.SharePoint.Security.WebPartPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
version="1" Connections="True" />
<IPermission class="System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1">
<ConnectAccess>
<URI uri=".*"/>
</ConnectAccess>
</IPermission>
</PermissionSet>
<Assemblies>
<Assembly Name="MyWebPart" />
</Assemblies>
</PolicyItem>
<PolicyItem>
<PermissionSet class="NamedPermissionSet" version="1" Name="Log4NetForMyWebPart"
Description="Permission set for Log4Net (logging library used by the My Web Part">
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Execution" />
<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1" Read="$AppDir$" Write="$AppDir$" Append="$AppDir$" PathDiscovery="$AppDir$" />
</PermissionSet>
<Assemblies>
<Assembly Name="log4net" />
</Assemblies>
</PolicyItem>
</CodeAccessSecurity>
</Solution>
You will have to dig into the MS documentation for the Permissions you need because it took me a while to figure out which ones I need.
The .wsp file was created with the command:
cabarc -r -p N ..\MyWebPart-1.0.0.wsp *
(I downloaded cabarc from the Microsoft website, but I don't remember exactly where)
To deploy the Web Part solution into SharePoint I use these commands:
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin
stsadm.exe -o addsolution -filename MyWebPart-1.0.0.wsp
stsadm.exe -o deploysolution -name MyWebPart-1.0.0.wsp -immediate -allcontenturls -allowCasPolicies
stsadm.exe -o execadmsvcjobs
The allowCasPolicies parameter is necessary because the solution contains CAS policies. Without it, they will not be added to the web.config file of SharePoint.
I have customized SharePoint master page Navigation menu by adding asp:XmlDataSource but I am getting "The control type 'System.Web.UI.WebControls.XmlDataSource' is not allowed on this page. The type is not registered as safe." Error.
I really appreciate any help.
You have to add the assembly as a safe control assembly in your web.config file.
<configuration>
<SharePoint>
<SafeControls>
<SafeControl Assembly="[Assembly Name]" Namespace="[Namespace]" TypeName="*" Safe="True" />
</SafeControls>
</SharePoint>
</configuration>
In your case it will be:
<SafeControl Assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="System.Web.UI.WebControls" TypeName="XmlDataSource" Safe="False" AllowRemoteDesigner="False" />
Add safe control entry in Your Package.Template.xml .This file you can findfile Path "\Package".
<Assemblies>
<Assembly
DeploymentTarget="GlobalAssemblyCache"
Location="YourDLLName.dll">
<SafeControls>
<SafeControl Assembly="YourDLLName,Version=1.0.0.0,Culture=neutral,PublicKeyToken=1b173e0e445783a8"
Namespace = "YourNameSpaceName"
Safe="True"
TypeName = "*"/>
</SafeControls>
</Assembly>
</Assemblies>