Archive for February, 2010

25
Feb
10

Setting up Outbound Email in SharePoint 2007 Using an Authenticated Outbound SMTP Account

Start by provisioning the MS SMTP server in your local infrastructure.  If you are using a single server, you can provision it on that server.

image

Make sure it’s set up to allow anonymous access (Properties | Access | Authentication) since SharePoint doesn’t provide a method to store SMTP server credentials.

image

Determine your login settings for your email provider’s authenticated SMTP account.  This may or may not require that you check the "TLS encryption" checkbox.

image

You may also find that you need to change the TCP port to a "secure" port.  587 is fairly common.

image

On the advanced delivery dialog, insert the name of your SMTP host in the "Smart host" field.  If you have a test domain that you are sending from (in this case, server1.awbikes.local), you might find you have to set the "Masquerade domain" so your email provider will accept the mail delivery.

image

You probably want to limit the connections that can be made to your SMTP server, especially if it is exposed where it could be hacked.  In this case, I have three machines that can connect to the SMTP server and use it to send email.

image

Finally, set the SMTP settings on the Operations | Outgoing E-Mail Settings page in Central Administration.

image

 

 

Advertisements
19
Feb
10

InfoPath Code to Hide All Toolbars When Filling Out a Form

There are probably several ways to do this, but this seemed pretty straightforward to me.  The code loops through the CommandBars collection that is part of Microsoft.Office.Core and sets the Enabled property to false.  If you want, you can selectively inspect each toolbar in the collection and enable/disable specific ones.

You can use the Context Changed Event to set a spiffy title for your form.  Be aware that, if the Context Changed Event is grayed out, you need to change the form’s browser compatibility options so it is not able to be opened in InfoPath Forms Services.

image

Uncheck the box “Design a form template that can be opened in a browser or InfoPath.”

image

Since we are using code, you’ll have to fully trust the form and sign it.

image

We’re using C# in this example, so set the form template code language to C#.

image

Add a reference to Microsoft.Office.Core by browsing to MSO.DLL in your Microsoft Shared folder.  You can see it here in my list of recent references.

image

image

Now you should be able to add the USING statement for Microsoft.Office.Core.

 

using Microsoft.Office.InfoPath;
using Microsoft.Office.Core; // Required for Commandbars
using System;
using System.Xml;
using System.Xml.XPath;
using System.Windows.Forms;
using mshtml;

namespace Test_Form
{
    public partial class FormCode
    {
        #region EventHandlers
        public void InternalStartup()
        {
            EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
            EventManager.FormEvents.ContextChanged += new ContextChangedEventHandler(FormEvents_ContextChanged);           
        }
        #endregion

        #region Toolbars

        public void FormEvents_ContextChanged(object sender, ContextChangedEventArgs e)
        {
            if (this.New)
            {
                this.Application.ActiveWindow.Caption = “Fill out my form!”;
            }
        }

        public void FormEvents_Loading(object sender, LoadingEventArgs e)
        {
            HideAllToolbars();
        }

        void HideAllToolbars()
        {
            // The main toolbar with the file menu will be hidden (msoBarTypeMenuBar)
            // along with all the other toolbars (msoBarTypeNormal)
            // if HideToolbarsFlag is true in the datasource
            /* List of enumerated menu bars
                Menu Bar msoBarTypeMenuBar 1
                Standard msoBarTypeNormal 2
                Print Preview
                Formatting
                Tables
                Ink
                Task Pane
                Property Editor
                Office Clipboard
                XML Source
                Research
                XML Document
                Signatures
                Document Actions
                Clip Art
                Selection and Visibility
                Document Management
                Document Updates
                Mail Merge Panes
                Fax Service
                Meeting Workspace
                Attachment Options
                Clipboard
                Envelope
                System
                Online Meeting
             * */
            XPathNavigator root = MainDataSource.CreateNavigator();
            string hideToolbarsFlag = root.SelectSingleNode(“//my:HideToolbarsFlag”, NamespaceManager).ToString();
            bool flag;
            if (hideToolbarsFlag.ToLower() == “true”)
            {
                flag = true;
            }
            else
            {
                flag = false;
            }

            CommandBars myCommandBars = this.Application.ActiveWindow.CommandBars as CommandBars;
            CommandBar myCommandBar = (this.Application.ActiveWindow.CommandBars as CommandBars).ActiveMenuBar;
            foreach (CommandBar item in myCommandBars)
            {
                //MessageBox.Show(item.Name.ToString() + ” ” + item.Type.ToString() + ” ” + item.Index.ToString());
                if (flag == true && (item.Type == MsoBarType.msoBarTypeMenuBar || item.Type == MsoBarType.msoBarTypeNormal))
                {
                    item.Enabled = false;
                }
            }
        }
        #endregion

    }
}

In order to control whether the toolbars are displayed or not, a field is added to the data source.  Add the element, HideToolbarsFlag, that will control whether or not to hide the toolbars.

image

image

This bit of code retrieves it’s value.  If you set the default value to true, it hides the toolbars; anything else, it doesn’t.

string hideToolbarsFlag = root.SelectSingleNode(“//my:HideToolbarsFlag”, NamespaceManager).ToString();

And now preview your form.

image

17
Feb
10

Checking for a NULL Date Field in SharePoint Designer Workflow

Since I originally published this, I’ve found that you can simply store the date in a dynamic string and then test the string to see if it is empty.  Use the “Build Dynamic String” action.

image

image

Testing the variable to see if it is empty.

image

Even easier!

 

Here’s the original post.

I was recently teaching an Advanced SharePoint class in Richardson, TX and a student was expressing his frustration over Microsoft’s apparent oversight within the SharePoint Designer workflow wizard. One of the “IF” conditions is a simple testing of the value of a field…”If this equals that.” He wanted to test a date field in SharePoint to see if it was empty or not. Problem is, when you select a field that is typed as DATE in SharePoint Designer, there is no test for the empty or null condition. You can see this in the first figure.

image

It occurred to me that we might be able to change the type of the field to a string and then be able to perform the comparison. I used the “Build Dynamic String” action.

image

I selected the End Date custom field on my Expense Statements list and stored it in a new variable that was typed as STRING.

image

The results of this were not exactly what I expected, however I was able to determine, through trial and error (sending the values in an email), that the conversion created a string that was filled with question marks (????). Therefore, if you simply test to see if the new string begins with a ?, you can successfully test for an empty date value.

image

Both my student and I were happy with the results.

15
Feb
10

Changing the Group on a Site Column Causes Hidden Fields to Display on a Content Type

I ran into this problem recently.  I had a number of site columns that were hidden on multiple content types and I "recategorized" the site columns into a single group (simply for administrative purposes).  As a result, all my forms began displaying the hidden fields (instead of keeping them hidden).

Here’s the scenario.  I have a content type, Generic Task, that is used as the parent of many other content types.  You can see from my first screen shot that I have a content type (called Badge Access Task) that is inheriting from Generic Task.  When a user interacts with the task list Edit form I only want them to see and update the two fields at the bottom (Badge Access and Badge Access Comments).  All the other fields are hidden and are only used by workflows.  If you haven’t done this before, you can still see the hidden fields in a view, but the New, Display and Edit forms don’t show the hidden fields.

clip_image002[11]

 

Here’s the problem I was having.  After I changed the group that my Generic Task site columns were in, they all started showing up on my Edit forms.

 

clip_image002[13]

 

To correct this problem, I simply went into each site column on each content type and clicked OK.  I didn’t make any changes to any of the information on the form.

 

clip_image002[15]

 

This appears to have had the desired effect.  After performing this procedure on each site column on the content types, all of my fields were again properly hidden.

 

clip_image002

 

As an FYI, this is on an MOSS 2007 farm with SP2 (and patches) applied.

05
Feb
10

Installing Adobe’s 64-bit PDF iFilter 9 on MOSS

I was working on a new installation for a client and convinced them to put their installation on a 64-bit machine. Their installation was only a single server install, but I still set up service accounts for all the bits (more specifically, I set up SPService for the app pool account and SPSearchReader for the content crawling account). After I got SharePoint installed and running, I went after the search to make sure it worked with all the necessary file types, PDF being a very important one.

In December of 2008, Adobe released their 64-bit iFilter 9, so I thought I’d give it a try. Adobe has an installation procedure, but for some reason I overlooked it on the first try.

After installing the iFilter I added the PDF extension to the list of file types to be crawled. I also installed the Acrobat reader on the machine so I could open the documents after I found them. I started a full crawl and ended up with about 3000 items in the search index from my test set of data. “Good,” I thought. As I started performing some searches I found that I couldn’t find any PDF documents. So, I checked the crawl logs. Here’s where I found the message, “The filtering process could not process this item. This might be because you do not have the latest file filter for this type of item. Install the corresponding filter and retry your crawl.” Well, I had just installed the iFilter, so what was up? It started smelling like a security problem.

One of the first security issues that sounded plausible was the security settings around the DCOM components. This is where your service account needs to be able to launch the IIS WAMREG admin Service. So, I launched dcomcnfg and edited the security to allow local launch and local activation for my two service accounts, SPService and SPSearchReader. I ultimately removed SPSearchReader, as it was not necessary.

clip_image002

After making these changes and retrying crawls multiple times and even rebooting the server, I was still getting the same error message. What were the potential issues? I thought about and researched several potential issues that came to mind.

· User rights assignment for the SPService or SPSearchReader accounts?

· DCOM permissions for IIS WAMREG admin Service.

· DCOM permissions for the Adobe iFilter thunking component (but this is native 64-bit, right? No more thunking.).

· Other Adobe DCOM object that needs permission updates?

· Directory permissions for the directory where the iFilter is installed? It already had read/execute for authenticated users.

· Adding the iFilter directory to the PATH environment variable?

I added the directory path where the iFilter is installed to the PATH environment variable. In this case, I added C:\Program Files\Adobe\AdobePDF9iFilter64\bin. I even rebooted the server. Same result.

I resorted to making SPService a member of the administrators group. Of course it worked after doing that. That’s the answer to every security problem, right? I took the SPSearchReader out of the administrator group and it continued to index PDFs. So, I took SPService out of the administrator group and lo and behold, it continued to work!

In one of the steps of the Adobe installation procedure (4.b.i), they mention changing the key \\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\12.0\Search\Setup\ContentIndexCommon\Filters\Extension\.pdf to the GUID {E8978DA6-047F-4E3D-9C78-CDBE46041603}. The original value was {4C904448-74A9-11D0-AF6E-00C04FD8DC02}. This appears to be a very important step! I tested the crawl using the new value of the GUID provided and the value that was already there. My tests showed that, if you don’t update the GUID, the iFilter won’t be able to index the PDF content. Perhaps this was my problem all along! I’m not completely sure and the only way I can make it fail now is by changing this registry key back to its original value.

clip_image004

After the PDF iFilter was working, I also installed the Microsoft iFilter pack and registered it with MOSS, according to article 946336. This is where I found there is a problem with the 64-bit Visio iFilter. Supposedly there is/will be a hotfix, but I couldn’t find one.  Hotfix 960502.

Since I first wrote this, it looks like MS has released their TIFF iFilter.  Index scanned documents…that’s cool!

05
Feb
10

InfoPath Forms Server Error: "There has been an error while loading the form. A required resource could not be downloaded. To try to resume the download, refresh the page."

image

If you see this error, "There has been an error while loading the form. A required resource could not be downloaded. To try to resume the download, refresh the page." there is likely a security problem on your site.  You may have a multiple server farm that is running your SharePoint site’s app pool under the Network Service account.  Try changing the account to a domain account that is properly configured per Microsoft’s recommendations.

Application pool identity:  The user account that the worker processes that service the application pool use as their process identity. This account is used to access content databases associated with the Web applications that reside in the application pool.

image

04
Feb
10

Establishing a Reference to InfoPath SemiTrust and InfoPath Xml Interop Libraries in VSTA

If you are attempting to use the namespaces

using Microsoft.Office.Core;
using Microsoft.Office.Interop.InfoPath.SemiTrust;
using Microsoft.Office.Interop.InfoPath.Xml;

in your VSTA project, you’ll find that you need to include some references. 

In order to get the Interop references, you may need to download and install Office 2003/2007 Primary Interop Assemblies (PIA) redistributable package.  You also want to make sure you have the .NET Programmability Support and VSTA installed for InfoPath.  You can use Add/Remove Programs in Office 2007 to insure you have .NET Programmability Support/Visual Studio Tools for Applications installed.

Add/Remove Programs showing interop assembly entries

image

Add/Remove features on Office 2007 showing InfoPath section

image

Now you need to add the references.  You’ll find the DLLs you need to reference in \Program Files\Microsoft Office\Office12.  Microsoft.Office.Interop.InfoPath.SemiTrust.dll and Microsoft.Office.Interop.InfoPath.Xml.dll.

.image

You can use the browse feature when adding the reference to find the DLLs.

image

The reference to Microsoft.Office.Core is from either the Microsoft Office 11.0 Object Library (Office 2003) or the Microsoft Office 12.0 Object Library (Office 2007).

image

 Happy automating!




Asif Rehmani’s SharePoint Videos

SharePoint-Videos

Click to access a wealth of SharePoint videos

SharePoint Rx

SharePoint Rx Home

Categories

Posts by Date

February 2010
M T W T F S S
« Jan   Mar »
1234567
891011121314
15161718192021
22232425262728
Support Wikipedia
Advertisements