public static bool GetEntryString(PwDatabase pwDb, string entry, out string password) { password = String.Empty; List <PwEntry> l = EntryMod.FindEntries(pwDb, entry); //if((args[ParamFailIfNoEntry] != null) && (l.Count == 0)) //throw new Exception(KSRes.EntryNotFound); foreach (PwEntry pe in l) { //if(pe.Strings.Get(strField) == null) //throw new Exception(KSRes.FieldNotFound); password = pe.Strings.ReadSafe("Password"); return(true); /* * if(bSprCompile) * { * SprContext ctx = new SprContext(pe, pwDb, SprCompileFlags.All, * false, false); * strData = SprEngine.Compile(strData, ctx); * * bNeedsSave = true; * } */ } return(false); }
public static void GetAllEntries(string databasefile, string keyfile, out ConcurrentDictionary <string, KeyValuePair <string, string> > dictionary) { // public static void ListEntries(PwDatabase pwDb) dictionary = null; DpiUtil.ConfigureProcess(); //needed? if (!KeePass.Program.CommonInit()) //check if in same dir as KeePass?? { KeePass.Program.CommonTerminate(); return; } IOConnectionInfo ioc = new IOConnectionInfo(); ioc.Path = databasefile; ioc.CredSaveMode = IOCredSaveMode.NoSave; CompositeKey cmpKey = new CompositeKey(); cmpKey.AddUserKey(new KcpKeyFile(keyfile)); if ((cmpKey == null) || (cmpKey.UserKeyCount == 0)) { return; } PwDatabase pwDb = new PwDatabase(); pwDb.Open(ioc, cmpKey, null); EntryMod.GetAllEntries(pwDb, out dictionary); pwDb.Close(); }