EMC Developer Network

Explicit Authentication to a Documentum Repository

December 2005

Software Environment

FeatureTested on
Operating SystemWindows 2000 Server SP4
ProgrammingLanguageC#
CompilerMicrosoft (R) Visual C# 2005 Compiler version 8.00.50727.42
Runtime Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
DFC5.3 SP1
Content Server5.3 SP1
DFC PIA5.3.0.53

Snippet


using System;
using System.Runtime.InteropServices;
using Documentum.Interop.DFC;

namespace CodeSnippets
{
	/// <summary>
	/// Summary description for ExplicitAuthentication.
	/// </summary>
	public class ExplicitAuthentication
	{

		public static void Main(String[] args)
		{
			ExplicitAuthentication ea = new ExplicitAuthentication();
			ea.Authenticate();
		}	

		String username = "dmadmin";
		String password = "dmadmin";
		String repository = "devprog";				

		private void Authenticate()
		{
			IDfClientX clientX = null;
			IDfClient localClient = null;
			IDfSessionManager sessMgr = null;
			IDfLoginInfo li = null;
			try
			{
				clientX = new DfClientXClass();
				
				li = clientX.getLoginInfo();
				li.setUser(username);
				li.setPassword(password);

				localClient = clientX.getLocalClient();
				sessMgr = localClient.newSessionManager();

				sessMgr.setIdentity(repository,li);

				sessMgr.authenticate(repository);
				Console.WriteLine("Authentication Successful");
				Console.ReadLine();
			}
			catch(Exception ex)
			{
				Console.WriteLine("Authentication Failed");
				Console.WriteLine(ex.Message);
				Console.WriteLine(ex.StackTrace);

			}
			finally
			{
				if(clientX != null)Marshal.ReleaseComObject(clientX);
				if(localClient != null) Marshal.ReleaseComObject(localClient);
				if(li != null) Marshal.ReleaseComObject(li);
				if(sessMgr != null) Marshal.ReleaseComObject(sessMgr);
			}
		}
	}
}