July 2009 Entries

This post was published to Dan Keeling on SharePoint C... at 12:36:06 PM 7/27/2009

Setup SMTP for your development SharePoint Environments

After wrapping up a project recently, a request came up for testing some custom email alerts, and email alerts from Workflow.

In the client’s development environment email was enabled, but there were some problems with the workflow. I had been working independently on my own VM, which was not on the domain and was not setup to send emails. So, to better test these things, I setup SMTP. I happened to know first-hand what an open/anonymous relay meant, and wanted to avoid that at all costs. After a little reading about settings and what to avoid, including sites that check for anonymous relays, I was off to setup the service and get things going. I thought I would just post some steps so that you can avoid mistakes, and get your SharePoint development VM’s sending emails. (Currently, at this specific client, they block SMTP, so I am running the local POP and SMTP service, so that I can check my emails.)

See this post on how to install the SMTP service. (Just like turning on IIS).
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true

Now after the service is running, open IIS manager. See the new area for Default SMTP Virtual Server:

clip_image002

Right-click on the “Default SMTP Virtual Server” and choose Properties.

clip_image004

Click on the Access Tab.

clip_image006

Let’s go through each area, in Authentication:

clip_image008

We want to enabled Anonymous access and Integrated Windows Authentication, don’t worry, we will restrict access to this server in a second, so you will not have an anonymous relay.

Click Ok.

clip_image006[1]

Click on Connection

clip_image010

Select the option for “Only the list below”, then add an entry as shown above, thus allowing only this local computer to access the SMTP service.
You can also add other local computers that you also wish to relay, just be careful, if you are on a laptop moving around from network to network.

Click OK.

clip_image006[2]

Click on Relay

clip_image012

Select “Only the list below” and check “Allow all computers which successfully authenticate to relay, regardless of the list above.

***Open relay or not???***
We are allowing everybody to relay, and we have anonymous access enabled, so are we are an open relay? NO, the restriction from the Access area is not allowing connections from other computers than this server, so we are not actually an open relay!

Click Ok.

clip_image006[3]

You can change other settings if you like, I just wanted a vanilla SMTP server running so I can get mails to send from SharePoint.

Click OK.

Now, our SMTP server will allow us to send emails from this computer and they will be relayed, but to where? We now need to define Relay Domains.

Expand the node for the “Default SMTP Virtual Server”.

clip_image014

Click on Domains

This list will only show the name of the local computer, so we need to add a couple other domains.

Right click and select New->Domain.

clip_image016

Select “Remote” and Click Next

clip_image018

Add *.com to allow for mail to be relayed to any .com address.

Follow the two previous steps to add .org and .net as needed. (Or for .tv, etc.)

clip_image020

That’s pretty much it! Set this server as the SMTP server in Central Administration, and you are ready to go.

A couple things to note, there is now a new folder at “C:\Inetpub\mailroot”, which contains the drop folder, queue, etc. You can also enable logging if you run into problems. I keep logging turned off on my box, I need to keep the space small.

Test your setup! Create a new AD account, add an email address for something at Gmail, or Hotmail, etc. Then add the user to any site and add an alert for that user, create an item in that list and you should get an email from your SharePoint server.

Hope it helps.

Well a co-worker sent me this link, so I thought I would go ahead and post it.

Microsoft has released Tech Prev. SharePoint 2010 developer documentation.

I will post back when I have more time to read through it.

http://www.microsoft.com/downloads/details.aspx?FamilyID=94afe886-3b20-4bc9-9a0d-acd8cd232c24&displaylang=en
I thought I would point out, that when a Site Collection is created in code, the AssociatedGroups are NOT created. Well, it just so happens that there is a method for this,

SPWeb.CreateDefaultAssociatedGroups see the full signature here,

public void CreateDefaultAssociatedGroups (
string userLogin,
string userLogin2,
string groupNameSeed
)
Parameters
userLogin
The account name of the primary administrator of the site.
userLogin2
The account name of the secondary administrator of the site.
groupNameSeed
The prefix for the names of groups in this site. If an empty string is passed, the prefix used is the site title.

Nice huh, well not so nice. First off, let me explain what happens internally. The site groups are created, the user names are then looked up in the Site Collection to add to the groups. Problem being, when the user is not already a member of the Site Collection, an exception is thrown, stating that the User cannot be found. This is what happens when you try:
internal code
if (!string.IsNullOrEmpty(strUserLogin))
{
currentUser = web.SiteUsers[strUserLogin];
}

There is no try-catch to handle this, so it just fails out.

Now what? One of two things, either add the user to the Site Collection prior to calling this method:

yourSite.RootWeb.SiteUsers.Add(username, email, name, String.Empty);

OR pass in null for both, it will use the current SPUser object, and then just add the user to the owners group afterwards.

if (yourSite.RootWeb.AssociatedOwnerGroup!= null)
{
yourSite.RootWeb.AssociatedOwnerGroup.AddUser(username, email, name, String.Empty);
}

And that should take care of it for you.
Looks like I got on a list to try out Office 2010, and other products relating to 2010, visio, infopath, etc. I am excited to see what is coming, and I will post about my thought and experiences when I get these things installed.
Cannot complete this action...

http://support.microsoft.com/?id=909455

I ran into this problem when trying to provision a new Site Collection from a workflow. This worked fine in my prototype WPF app, but failed everytime when the WF ran.

I threw in the suggestions from the article,

WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate();

and in my finally block,

wic.Undo();

and it seems to be a work-around, but really...
After a couple of days working with the new install, I like it for the most part, one thing that I found, there is no hibernate option with a Server OS and Hyper-v configured... so I shut down more often that I used to. Also, to get the Hyper-V networking to work, the problem is that you cannot use the wireless adapter as a share for the virtual networks, the virtual networks attach to the physical ehternet adapter. The workaround, was to bridge connections from my wireless and the virtual adapter, and things work out pretty well. Also, it seems much easier to remote desktop into a machine instead of using the Hyper-V manager/machine consoles to work on the machines. It is kind of silly to remote desktop into your own machine, but it has much better performance.

Also, some anti-virus programs interfere with Hyper-V mmc snap-in apparently. When I had anti-virus running (mcafee and norton) mmc crashes whenever I tried to open the Hyper-V manager. TrendMicro works for me.
I should really say dev box, but it is a laptop, so it is not all that powerful.

I have a Dell D620 and have windows server 2008 r2 (win2k8) installed on it.

I ran into a couple things I would like to post about.

The main reason I have loaded this is to use hyper-v, I need to be able to run multiple virtual machines, some windows server 2003, some 2008, some 32 and 64 bit. Also, sometimes I need special flavors of SharePoint or SQL server to match a client implimentation.

I keep a vm of Windows 7 as well, which I use for Outlook and other things.

Each of my VM's has Visual studio, and my suite of tools, (found in another post).

Back to the Server, I mean dev box.

I did a clean install of Windows Server 2008 R2 x64 (wanted to use all 4GB of ram)

After things were finished, I noticed that hardware was all detected, except video, and I had no wireless connection.

Off to find the video drivers, but wait... no wireless connections.

In server OS's now, you have to enable the wireless "feature", then everything works.

So that others can find it, wireless network not found or no wireless networks shown in windows server 2008.

Enjoy.