Retrieving User Information in InfoPath without Code – One solution to ‘Value cannot be null. Parameter name: serverContext’

InfoPath, SharePoint and Web Services are becoming sparring partners for me of late. 

In order to retrieve user information in my InfoPath form I followed the instructions at itaysk’s blog, as I wasn’t aware I could use a SharePoint Web Service to get profile information.  Sweet – I thought.

I then immediately got:

The User Profile Manager object could not be loaded. —> Value cannot be null. Parameter name: serverContext

This was an error noted by quite a few people, but with very few solutions.

I then got out Fiddler as I do, to see what was going on, and remembered that InfoPath tends to expand url’s into their fully qualified domain names (FQDN) – so you may have entered http://mylocalnetworkserver/_vti_bin/etc.asmx but if you’re on a corproate network or anywhere with DNS happening then you’ll suddenly find yourself calling http://mylocalnetworkserver.some.other.domain.gumph/_vti_bin/etc.asmx.

Why is this important you ask?  – Well I then thought ‘I’m sure there wouldn’t be anything logged on the server?’  – well SharePoint probably logs a lot more than most realise, but the error in this case was staring me in the face in the Event Log:

A Windows SharePoint Services Error – Event ID 8214.

A request was made for a URL, http://mylocalnetworkserver.some.other.domain.gumph, which has not been configured in Alternate Access Mappings.  Some links may point to the Alternate Access URL for the default zone, http://mylocalnetworkserver.  Review the Alternate Access mappings for this Web application at http://mylocalnetworkserver:1234/_admin/AlternateUrlCollections.aspx and consider adding http://mylocalnetworkserver.some.other.domain.gumph as a Public Alternate Access URL if it will be used frequently.  Help on this error: http://go.microsoft.com/fwlink/?LinkId=114854.

Well blow me down.  All the other web services I call from InfoPath don’t care about this because they’re not hosted in SharePoint, and SharePoint manages the allowed paths into the application. 

Once I went to the Central Admin site –> Operations –> Alternate Access Mappings, and edited ‘Public Zone URLs’ to add the FQDN to the intranet zone (probably could choose any zone), it just started working.

Setup Single Sign-on for SharePoint 2007. The missing link

I need to use the SharePoint 2007 Single Sign-on service for the purposes of InfoPath Form authentication on Web Services.  I went through the Microsoft installation steps and immediately got

You do not have the rights to perform this operation.

A bit of googling later, and I found that this isn’t uncommon. 

Looking at Dave Wollerman’s post on the subject made me check everything again.

In the end the missing link (that I failed to read) from the Microsoft doc was simply that the Single Sign-on Windows service needed to be running with a domain account (I chose the same as the administrator accounts), and it then worked fine. 

Deploying the minimum Oracle Instant Client files with ODP.NET

If you’re looking for the smallest and least hassle deployment of Oracle client files with a .NET application, then forget about everything else you’ve been told – the following did the trick for me, and involves just 5 Oracle dll’s.

Deploying ODP.NET with Oracle Instant client

One thing I found with this was that on my dev machine I already have (more than) one ‘standard’ Oracle installation and all the network config from that was really getting in the way meaning I couldn’t connect for one reason or another – OR I was connecting, but not using the correct client, meaning deployed files wouldn’t work on a ‘virgin’ machine.  All of this rather depends on how your company deploys Oracle server and clients I guess.

Rather than muck about with setting environment variables (that’s so 80’s) if you use a full connection string syntax as follows you can use your hostname and SID rather than try and fathom out service names. 

In your web.config

  <add name=”MyDB” connectionString=”Data Source=(DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = machinename)(PORT = 1521)))(CONNECT_DATA =(SID = mysid)));User Id=username;Password=password;” providerName=”” />

Any other variation of the (mucho confusing) Oracle connection syntax just didn’t work for me.

As an aside – I also kept getting System.OutOfMemoryException when building a web site project in Visual Studio 2008 when I was using the Oracle Basic client dll’s (110mb +).  I switched to the smaller Basic ‘Lite’ versions and it was happy again.  I guess a single file of over 100mb blows the lid off the IDE.

Software Developer vs Project Manager

I came across a hilarious (full of swearing) video the other day created through Xtranormal.com.  This amazing site gives you all the tools to just plug in a script and direct your own movie, along with amusing generated voices.

Here’s my first effort to illustrate the sometimes rocky relationship between developers and project managers…

Watch on Xtranormal.com | Watch on Youtube

SQL Server Stored Procedure to disable / enable all foreign keys and constraints in a database

I’ve been doing a bit of batch archiving work, and needed a nice and quick way to disable foreign keys and other constraints without actually removing them.  I found a nice article on disabling all constraints in a database, and thought I’d just take it one step further by making it into a Stored Procedure, and adding a parameter to toggle whether the constraints are enabled or disabled.

Nice and easy.  Here’s the script.

USE [YOURDBNAME]
GO

IF  EXISTS (SELECT FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_SetDBTableConstraints]’AND type in (N’P’N’PC’))
DROP PROCEDURE dbo.usp_SetDBTableConstraints
GO

CREATE PROCEDURE dbo.usp_SetDBTableConstraints(@Enable BIT)

AS

/*** DISABLE/ENABLE ALL TABLE CONSTRAINTS ************************

This script will disable all constraints on all tables within the database
that it is run in.

************************************************************/

SET NOCOUNT ON
SET ROWCOUNT 

DECLARE @Count INT
DECLARE 
@String NVARCHAR (1000)
DECLARE @ConstraintName VARCHAR(128)
DECLARE @TableName VARCHAR(128)

–Find all constraints and their respective tables from the sysobjects table and place into a temp table.
–Primary Key and Unique Constraints via Unique Indexes are not disabled through this command
–You should use the ALTER INDEX…DISABLE command in SQL Server 2005
SELECT 
        name                     AS 
constraintname,
        object_name(parent_obj)  
AS tablename 
INTO #Const_Table
FROM sysobjects s 
where xtype in (‘F’)

SELECT @Count Count(*) FROM #Const_Table

–Setting the rowcount to one allows for one row from the temp table to be picked off at a time.
–Used as an alternative to a cursor.
SET ROWCOUNT 1

–Loop until all rows in temp table have been processed.
WHILE @Count > 0
BEGIN
    
–The rowcount of one ensures that only one tablename and constraint name is picked.
    
SELECT @TableName TableName, @ConstraintName ConstraintName
    
FROM #Const_Table

    –Build execution string to disable constraint.
    
IF @Enable 
        
SET @String ‘ALTER TABLE [‘+ @tablename + ‘] CHECK CONSTRAINT [‘ + @constraintname +‘]’
    
ELSE
        SET 
@String ‘ALTER TABLE [‘+ @tablename + ‘] NOCHECK CONSTRAINT [‘ + @constraintname +‘]’

    –Execute the SQL
    
EXEC sp_executesql @string

    –Remove this row from the temp table, since it has now been processed.
    
DELETE FROM #Const_Table WHERE ConstraintName @ConstraintName and TableName @TableName

    SET @Count @Count – 1
END — Loop

SET ROWCOUNT 0

DROP TABLE #Const_Table
 

GO

Remote Desktop Clipboard Not Working? – Just restart rdpclip

This one’s been bugging me for years.  You know the situation, you’re happily using a remote desktop connection, and all of a sudden the clipboard stops working for no apparent reason.

I recently stumbled across a ‘fix’ for this.  It’s more of a workaround than a fix, as you’ll need to do it every time the clipboard disappears.

Just look for a process named rdpclip.exe on the machine you’re remoting to, and kill it, then restart it.

You should find you’re able to copy/paste again.