Error Connecting Using Vault API

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
dschrenk
Posts: 10
Joined: Fri Feb 24, 2006 11:53 am

Error Connecting Using Vault API

Post by dschrenk » Fri Mar 24, 2006 12:40 pm

I am having a very strange problem. I have been working on an app in VS.NET in C# that uses the Vault API v3.1.7 to retreive files from our Vault Server. Recently I had to re-install my computer and after I moved the entire project back on the fresh machine I began receiving an error when connectin to vault:
"The path is not of a legal form."
Here's the StackTrace:

Code: Select all

at System.IO.Path.nGetFullPathHelper(String path, Char[] invalidPathChars, Char[] whitespaceChars, Char directorySeparator, Char altDirectorySeparator, Char volumeSeparator, Boolean fullCheck, String& newPath)
at System.IO.Path.FixupPath(String path)\r\n   at System.IO.Path.GetDirectoryName(String path)
at VaultClientOperationsLib.VaultClientConfigReader.MakeAllDirectories(String path)
at VaultClientOperationsLib.VaultClientConfigReader..ctor(String scope, String strDefLocation)
at VaultClientOperationsLib.LocalSettings.Init(LocalSettingsScope scope, String strDefaultConfigDir)
at VaultClientOperationsLib.LocalSettings.Init(LocalSettingsScope scope)
at VaultClientOperationsLib.ClientInstance.Init(AccessLevelType accessLevel)
at MB_WebClient_Mngr.classes.VaultConnect.Connect() in c:\\inetpub\\wwwroot\\mb_webclient_mngr\\classes\\vaultconnect.cs:line 80
Anyone know whats going on?

Thanks,
D

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Post by lbauer » Fri Mar 24, 2006 5:22 pm

Did you use some relative paths in your app that may not be valid when you moved the project to the new machine?
Linda Bauer
SourceGear
Technical Support Manager

dschrenk
Posts: 10
Joined: Fri Feb 24, 2006 11:53 am

Post by dschrenk » Fri Mar 24, 2006 8:36 pm

No.

After looking at the StackTrace, It seems to be an error within the API. I have re-installed VS.NET and the .NET Framework to rule those out.

This is happening before any paths are used though. Its on the mlClient.Init (ClientInstance.Init) function.

Here's the entire class:

Code: Select all

using System;
using System.Collections;
using VaultClientOperationsLib;
using VaultLib;
using VaultClientNetLib.ClientService; 
namespace VaultManager.classes
{

public class VaultConnect {
	public static ClientInstance mlClient;
	private static string _hostName = constant.c_HOSTNAME;

	public static void Connect () {
		string username; 
		string password;
		mlClient = new ClientInstance();
	
		try {
			if (UserInfo.SecurityLevel == 1) {
		
				username = constant.c_ADMIN_USER;
				password = constant.c_ADMIN_PASS;
				mlClient.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Admin);

			} else {
		
				username = constant.c_USER_USER;
				password = constant.c_USER_PASS;
				mlClient.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client);
			}

			if (_hostName.StartsWith("http://") == false)
				_hostName = "http://" + _hostName;
			if (_hostName.EndsWith("/VaultService") == false)
				_hostName += "/VaultService";
				
			mlClient.Login(_hostName, username, password);
		}
		catch (Exception e) {
			e = new Exception("Error logging into Vault.<br>" + e.Message);
			throw e;
		}
	}
}

}

dan
Posts: 2448
Joined: Wed Dec 17, 2003 5:03 pm
Location: SourceGear
Contact:

Post by dan » Mon Mar 27, 2006 10:57 am

Does the command line client work when you connect to the same server you are attempting to connect to here? If so, you might debug both the CLC and this app, and compare what is being sent to client.Login(), and make sure they are the same.

dschrenk
Posts: 10
Joined: Fri Feb 24, 2006 11:53 am

Post by dschrenk » Mon Mar 27, 2006 12:08 pm

The Command Line Client works. The only problem is client.Login() isn't where I'm getting the error its on client.init(). (see line 8 of the stacktrace at VaultClientOperationsLib.ClientInstance.Init(AccessLevelType accessLevel)) I did make one adjustment to my function to match client.init() from the CLC, its for the AccessLevelType, see bleow:

Code: Select all

public static void Connect () {
	string username; 
	string password;
	mlClient  = new ClientInstance();
			
	try {
				
		// get access level req'd by the command
		VaultConnection.AccessLevelType AccessLevel = (UserInfo.SecurityLevel > 1) ? VaultConnection.AccessLevelType.Client : VaultConnection.AccessLevelType.Admin;

		if (UserInfo.SecurityLevel == 1) {
			username = constant.c_ADMIN_USER;
			password = constant.c_ADMIN_PASS;
		} else {
			username = constant.c_USER_USER;
			password = constant.c_USER_PASS;
		}

		if (_hostName.StartsWith("http://") == false)
			_hostName = "http://" + _hostName;
		if (_hostName.EndsWith("/VaultService") == false)
			_hostName += "/VaultService";
				
		mlClient.Init(AccessLevel);
		mlClient.Login(_hostName, username, password);

		VaultConnect.ConnectionState = true;
	}
	catch (Exception e) {
		e = new Exception(e.Message);
		throw e;
	}
}
}

dan
Posts: 2448
Joined: Wed Dec 17, 2003 5:03 pm
Location: SourceGear
Contact:

Post by dan » Mon Mar 27, 2006 4:56 pm

The exeption it is throwing happens when you don't have access to the registry in order to retrieve some Vault configuration data.

Is this running under a process without access to the registry?

dschrenk
Posts: 10
Joined: Fri Feb 24, 2006 11:53 am

Post by dschrenk » Tue Mar 28, 2006 7:47 am

Thats exactly what it was!!!
The local IIS user did not have access to the registry. I set the anonymous user to a user that has access to the registry and it worked!

Thank you very much!

-David

Post Reply