Page 1 of 1

Connecting using profiles

Posted: Mon Jul 16, 2007 8:48 am
by amaslar
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?

Posted: Mon Jul 16, 2007 3:56 pm
by shannon
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("");
			}