Connecting using profiles

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
amaslar
Posts: 3
Joined: Fri Jun 08, 2007 8:10 am

Connecting using profiles

Post by amaslar » Mon Jul 16, 2007 8:48 am

I am trying to write an application to automate our release process, and am attempting to use the Vault API. I would like to be able to connect to the server using profiles, rather than prompting for username/password. I have located the Profile class in the API but I can't figure out how to use it. Can you offer some guidance?

shannon

Post by shannon » Mon Jul 16, 2007 3:56 pm

The code snippet below shows how to get a list of available profiles and access some of the profile info. Does this help answer your question?

Code: Select all

			// initialize a new ClientInstance
			ClientInstance ci = new ClientInstance();
			ci.Init(VaultConnection.AccessLevelType.Client);

			// use ClientInstance to retrieve the LoginProfiles object
			LoginProfiles profiles = new LoginProfiles(ci);
			// get a list of the profiles, this is essentially a list of the profile names
			ArrayList listOfProfiles = profiles.ListProfiles();

			for (int i = 0; i < listOfProfiles.Count; i++) 
			{
				// for each item in the list, retrieve the profile with that name
				// and access the info
				LoginProfiles.Profile p = profiles.GetProfile(listOfProfiles[i].ToString());
				Console.Out.WriteLine("Profile name:  " + p.ProfileName);
				Console.Out.WriteLine("Username:  " + p.UserName);
				Console.Out.WriteLine("Password:  " + p.Password);
				Console.Out.WriteLine("Server:  " + p.Server);
				Console.Out.WriteLine("");
			}

Post Reply