Showing posts with label DLL. Show all posts
Showing posts with label DLL. Show all posts

Tuesday, January 13, 2009

Dealing with Microsoft UDDI services

How do I install and setup Microsoft UDDI Services?

Read the UDDI SOA Howto.

Where to get the UDDI samples?


Microsoft did not include the UDDI samples in the current Windows SDK for Windows Server 2008 and .Net Framework 3.5.

Therefore you need to install the old Windows Server 2003 SDK .

After you installed the Core SDK you find the samples in

%PROGRAMFILES%\Microsoft SDK\samples\UDDI


Where to get Microsoft.UDDI.DLL?

You find it if you install the Windows Server 2003 SDK you find it in

%PROGRAMFILES%\Microsoft SDK\bin

or if you installed .NET 3.0 you find it in

%PROGRAMFILES%\Reference Assemblies\Microsoft\UDDI\v2.1\bin\system32


How to turn on Debugging?


If you want to turn on Debugging use regedit and goto:

[HKLM\SOFTWARE\Microsoft\UDDI\Debug]

set FileLogLevel to the appropriate value. Possible values are:

0 = None
1 = Error,
2 = Warning,
3 = FailAudit,
4 = PassAudit,
5 = Info ,
6 = Verbose

where 6 (Verbose) prints the most information into the file specified by LogFileName

How to configure another virtual directory for UDDI?

Open the IIS Manager, right click on Default Web Site and select New Virtual directory. Select a name for the alias, then select the UDDI/webroot folder (e.g. "c:\inet\uddi\webroot" ). Then select the Read, Run Scripts and Browse permission. After the wizard finishes right click on the virtual directoy and select Properties. Now change the Application Pool to "MSUDDIAppPool". Last thing is to select the ASP.NET tab and change the ASP.NET Version to 1.1.4322.

How to configure Authentication?

Microsoft UDDI offers basically 2 different types of authentication.

Windows Authentication and UDDIAuthentication. The difference is that in Windows Authentication you do not have to specify a Username and Password when you create the UDDIConnection object.

Windows Authentication
In Windows Authentication you do not have to specify a Username and Password. UDDI simply takes the Usercredentials received by the UDDI web service. To configure UDDI for using Windows credentials open the IIS Manager, right click the virtual directory (e.g. uddi or uddipublic), go to the Directory Security tab and click on Authentication and access control. Now make sure "Enable anonymous access" is disabled and Authenticated access is set to Integrated Windows authentication.

Ok, whats UDDIAuthentication?
When you use UDDIAuthentication you specify a Username and Password when you create the UDDIConnection object. However this user has to be a valid windows user account and has to have appropriate permissions. Using UDDIAuthentication the authentication of the account is not enforced by IIS but the UDDI Service will authenticate the user.
To configure UDDI for doing UDDI authentication open the IIS Manager, right click the virtual directory (e.g. uddi or uddipublic), go to the Directory Security tab and click on Authentication and access control. Now make sure "Enable anonymous access" is enabled.

Now use the following pattern:

UddiSiteLocation location = new UddiSiteLocation(
httpServerName + "inquire.asmx",
httpsServerName + "publish.asmx",
httpServerName + "extension.asmx",
"My Site",
AuthenticationMode.UddiAuthentication);

UddiConnection oConnect = new UddiConnection(location, @"Domain\Username", "Password");

oConnect.AutoGetAuthToken = true;

The secret to UDDI Authentication
1.) Try to the current user out the current HTTPContext (Windows Authentication)
2.) Query the Security.Authentication Mode Parameter which is set in the UDDI Database in table UDO_config.
3.) If the Security.Authentication Mode parameter is set to 8 UDDI tries Passport authentication.
4.) Windows Authentication is only used if the current user is not the anonymous user (Anonymous Access is disabled) and you did not specify a username in the connection.
5.) By Default UDDIAuthentication is used.


public AuthToken GetAuthToken(GetAuthToken gat)
{
Debug.Enter();
AuthToken token = new AuthToken();
try
{
IIdentity identity = HttpContext.Current.User.Identity;
int @int = Config.GetInt("Security.AuthenticationMode", 3);
if (8 == @int)
{
if (!(identity is PassportIdentity))
{
throw new UDDIException(ErrorType.E_fatalError, "UDDI_ERROR_PASSPORT_CONFIGURATION_ERROR");
}
Debug.Write(SeverityType.Info, CategoryType.Soap, "Generating credentials for Passport based authentication
dentity is " + gat.UserID);
PassportAuthenticator authenticator = new PassportAuthenticator();
if (!authenticator.GetAuthenticationInfo(gat.UserID, gat.Cred, out token.AuthInfo))
{
throw new UDDIException(ErrorType.E_unknownUser, "USER_FAILED_AUTHENTICATION");
}
if (!authenticator.Authenticate(token.AuthInfo, 0x3840))
{
throw new UDDIException(ErrorType.E_unknownUser, "UDDI_ERROR_USER_FAILED_AUTHENTICATION");
}
if (!Context.User.IsVerified)
{
throw new UDDIException(ErrorType.E_unknownUser, "UDDI_ERROR_NOT_A_VALID_PUBLISHER");
}
}
else if ((!((WindowsIdentity) identity).IsAnonymous && ((@int & 2) != 0)) && Utility.StringEmpty(gat.UserID))
{
Debug.Write(SeverityType.Info, CategoryType.Soap, "Generating credentials for Windows based authentication
Identity is " + identity.Name);
new WindowsAuthenticator().GetAuthenticationInfo(gat.UserID, gat.Cred, out token.AuthInfo);
}
else
{
if ((@int & 1) == 0)
{
throw new UDDIException(ErrorType.E_unsupported, "UDDI_ERROR_AUTHENTICATION_CONFIGURATION_ERROR");
}
Debug.Write(SeverityType.Info, CategoryType.Soap, "Generating credentials for UDDI based authentication");
new UDDIAuthenticator().GetAuthenticationInfo(gat.UserID, gat.Cred, out token.AuthInfo);
}
Debug.Write(SeverityType.Info, CategoryType.Soap, "Windows Identity is " + WindowsIdentity.GetCurrent().Name);
Debug.Write(SeverityType.Info, CategoryType.Soap, "Thread Identity is " + Thread.CurrentPrincipal.Identity.Name);
Debug.Write(SeverityType.Info, CategoryType.Soap, "HttpContext Identity is " + identity.Name);
Debug.Verify(Context.User.IsPublisher, "UDDI_ERROR_NO_PUBLISHER_CREDENTIALS", ErrorType.E_fatalError, new
bject[] { Context.User.ID });
Debug.Write(SeverityType.Info, CategoryType.Authorization, "Authenticated user (userid = " + gat.UserID + " )");
}
catch (Exception exception)
{
DispositionReport.Throw(exception);
}
return token;
}


Errors and Solutions

If authentication fails with "Authetication failed" and in the UDDI log you will see.

FAIL AUTH 2009/01/13 18:09:14 System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at UDDI.API.Authentication.UDDIAuthenticator.GetAuthenticationInfo(String userid, String password, String& ticket)

Dont forget to put an @ before the string specifying the username so use:

string szUsername = @"Domain\User";

Thursday, September 4, 2008

.Net and Oracle 10. Welcome to DLL Hell

Until Oracle 8 or 9 you installed the client, chose whether you want to use Oracle Driver (Oracle.DataAccess.dll) or the Microsoft Driver (System.Data.OracleClient) and you had a happy connection to your database.

Installing a OracleClient and connecting to a Oracle Database with was until a day in August 2008 a Non-Event. 15 minutes and off you go.

Now we upgraded our database backend to Oracle 10 as anything else is running out of maintenance.

"Ok", I thought. "Business as usual". "Install the latest client, turn on, works".

What I didn't know was that I was standing on the doorstep to Oracle DLL Hell.

First everything looked just smooth. After upgrading the client from Oracle 8 to 10, the connection with System.Data.OracleClient to our Production environment on Oracle 9 was just fine. No problems here.

The problems started when I first tried to connect with an Oracle 10 the same database only on Oracle 10.

4 out of five queries worked fine but then

"ORA-01405: fetched column value is NULL" System.Data.OracleClient

The error message means basically that I tried to fetch a null value into a PL-SQL variable.

Only Problem here. I use a common SQL here. So no fetch anywhere.

We now invested much much time in solving this problem, upgraded the server to latest patchlevel and lots of different things. Nothing helped. So the only way to solve this problem was to switch to the native Oracle .NET driver.

After switching to the native Oracle Driver (Oracle.DataAccess.dll) the problem was solved. Only problem that remained now, was that my version of the client 9 was not installed on the server and hence I would not be able to install the software on the server with that dll.

Ok, I thought. Lets get rid of my Oracle 9 and install a Oracle 10.2.0.3 client. The same client as installed on the server.

Sooner said than done. I chose "Application Developer" option and off I went.

But when I tried to add the reference to the Oracle .Net driver (Oracle.DataAccess.dll) using the "Add reference" dialog in Visual Studio .Net 2008 I found.... nothing. Obviously .Net Application Development is no longer in focus when installing the Oracle Client, but I knew that Oracle has special packages for .Net.

Installing Oracle Data Provider for .Net (10g).

Why the fuck the installer recommends to create a new Oracle Home instead of installing it where it belongs (the exsting Oracle Home of my 10.2.0.3 client directory)?

Very important: At the point where you can choose the target directory, make sure you select the existing client directory, by selecting the proper Oracle Home Name.

I cost me 1.5 days to find out, that by default, the installer creates a new Home Directory, where it simply doesn't do anything but to throw exceptions.

After installing the ODAC correctly you find it in your "Add reference" Dialog unter .NET components under "Oracle.DataAccess".

5 Cents on .NET and Oracle 10

The story is longer but here are my 5 cents:

  • Make sure the Oracle client version on your development and production machine are the same
  • To get a working .NET driver, you need to additionally install the Oracle Data Access Components for .NET which can be found here .
  • Make sure, you select the proper version of the ODAC for your client.
  • When the bloody Oracle installer asks you for the directory make sure you select the existing directory of your client.
Dear guys at Oracle. In the last 2 days I really learned to hate your "Oracle Universal Installer". The setups are full of flaws, misleading informations, bugs, crc errors, bad recommendations or unnecessary components.
And why the hell, the Developer Oracle Client Package does not include a .Net Driver?
By today I can call myself Oracle Client Setup Expert (OCSE), for a thing that should be what it is: a non-event