Managing web.config entries using SPWebConfigModification

17 09 2008

This is no news to everybody working on the field with structured solution deployment, but if you are giving your first steps or still feelling like your on a roller coster with the solution packaging of WSS/MOSS, than this may come in handy. You probably did or will come alonga situation when you need to add entries to your web.config on deployment; and of corse, these should be removed on uninstalling…

OK, so cut to the chase: SPWebConfigModification is your object!

This object lives in Microsoft.SharePoint.dll and provides a series of methods to manipulate the configuration settings of your web application.

Take care, though: safecontrols should be added using the WSP (Web Solution Package) deployment.





Active Directory and ASP.NET 2.0

16 09 2008

While trying to create something as simple as a forms authentication mechanism with as Active Directory provider, I came accros a nice set of problems.

The main issue had to do with the actual connection to the active directory itself.

All done by the book and still no connection. How do you deal with this? Forget debug… you have to go lower.

I started by using ADSIEDIT, a tool that comes with ADAM. With this tool, you can connect and navigate a remote active directory. It worked, no problem, so there was no network problem. Opening a command prompt in the domain controller machine and executing the netstat -a command, I could see my machine connecting to the LDAP port.

After that I tried to run my web aplication and.. no deal. No ports oppening, no nothing.

I then added the following lines of code in the .cs file in order to try to undernstand if the connection was established:

        string appName = Membership.ApplicationName;

An exception is then thrown with the text

“System.Configuration.ConfigurationErrorsException was unhandled by user code
  Message=”Unable to establish secure connection with the server (C:\\bla\\bla\\WebSites\\DevelopmentWebsite\\web.config line 117)”
  Source=”System.Web”
  BareMessage=”Unable to establish secure connection with the server
  Filename=”C:\\bla\\bla\\WebSites\\DevelopmentWebsite\\web.config” Line=117
  StackTrace:
       at System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
       at System.Web.Configuration.ProvidersHelper.InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType)
       at System.Web.Security.Membership.Initialize()
       at System.Web.Security.Membership.get_ApplicationName()
       at _Default.Logon_Click(Object sender, EventArgs e) in c:\bla\bla\WebSites\DevelopmentWebsite\Login.aspx.cs:line 39
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

By the time I got knocking my head against the walls, I found this information: How to enable LDAP over SSL with a third-party certification authority

That was it… It solved my problem.

Here are a couple of good information on this topic. Hope they help you. They helped me :)





An error ocurred during the process of … Code Block are not allowed in this file.

15 09 2008

Oh well, whenever I start a project, there I go hitting this message.

Just as a reminder: if you want to solve this, you just have to edit your web.config file and set the gallery you want to run code in. For example, if this happened caused by some code added tou the blueband.master masterpage, you will have to modify :

<Configuration>

<Sharepoint>
<Safemode …>
<PageParserPaths>
<PageParserPath VirtualPath=”/_catalogs/masterpage/*” CompilationMode=”Always” AllowServerSideScript=”True” IncludeSubfolders=”True” />
<PageParserPaths>
</Safemode>

Just as a hint, if you have some sort of framework, it may be useful to add this line on install.








Follow

Get every new post delivered to your Inbox.

Join 425 other followers