diff --git a/c_micasad/init/CredMgr.cs b/c_micasad/init/CredMgr.cs new file mode 100644 index 00000000..e4add38d --- /dev/null +++ b/c_micasad/init/CredMgr.cs @@ -0,0 +1,139 @@ +/*********************************************************************** + * + * Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, Novell, Inc. + * + * To contact Novell about this file by physical or electronic mail, + * you may find current contact information at www.novell.com. + * + ***********************************************************************/ + +using System; +using System.IO; +using System.Diagnostics; + +namespace sscs.init +{ + /// + /// Summary description for RegCredMgr. + /// + public class CredMgr + { + public CredMgr() + { + } + + public static void Install() + { + System.Diagnostics.Debug.WriteLine("CASA: attempting to register lcredmgr"); + string sExePath = GetRegSvrPath(); + if (sExePath != null) + { + string sCredMgrPath = GetCredMgrPath(); + if (sCredMgrPath != null) + { + RunProcess(sExePath, "/i /n /s " + "\"" + sCredMgrPath + "\""); + } + } + } + + public static void Uninstall() + { + System.Diagnostics.Debug.WriteLine("CASA: attempting to unregister lcredmgr"); + string sExePath = GetRegSvrPath(); + if (sExePath != null) + { + string sCredMgrPath = GetCredMgrPath(); + if (sCredMgrPath != null) + { + RunProcess(sExePath, "/u /s " + "\"" + sCredMgrPath + "\""); + } + } + + } + + + private static void RunProcess(string sProcess, string sArgs) + { + if (sProcess != null) + { + try + { + Process myProcess = new Process(); + ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(sProcess); + + if (sArgs != null) + myProcessStartInfo.Arguments = sArgs; + + myProcessStartInfo.UseShellExecute = false; + myProcess.StartInfo = myProcessStartInfo; + myProcess.Start(); + myProcess.WaitForExit(); + System.Diagnostics.Debug.WriteLine("Completed " + myProcess.ExitCode.ToString()); + } + catch (Exception e) + { + System.Diagnostics.Debug.WriteLine(e.ToString()); + } + } + } + + + private static string GetRegSvrPath() + { + string sPath = Environment.GetEnvironmentVariable("SystemRoot"); + if (sPath != null) + { + // look for regsvr32.exe + if (File.Exists(sPath + "\\system32\\regsvr32.exe")) + { + return (sPath + "\\system32\\regsvr32.exe"); + } + else + { + System.Diagnostics.Debug.WriteLine("Did not find regsvr32.exe"); + } + } + else + { + System.Diagnostics.Debug.WriteLine("Did not find System path"); + } + + return null; + } + private static string GetCredMgrPath() + { + string sPath = Environment.GetEnvironmentVariable("ProgramFiles"); + if (sPath != null) + { + // look for regsvr32.exe + if (File.Exists(sPath + "\\Novell\\CASA\\bin\\lcredmgr.dll")) + { + return (sPath + "\\Novell\\CASA\\bin\\lcredmgr.dll"); + } + else + { + System.Diagnostics.Debug.WriteLine("Did not find lcredmgr.dll"); + } + } + else + { + System.Diagnostics.Debug.WriteLine("Did not find path to [ProgramFiles]"); + } + + return null; + } + } +} diff --git a/c_micasad/init/WinSecretStoreClientService.cs b/c_micasad/init/WinSecretStoreClientService.cs index 961d0409..7a1fde9b 100644 --- a/c_micasad/init/WinSecretStoreClientService.cs +++ b/c_micasad/init/WinSecretStoreClientService.cs @@ -99,12 +99,14 @@ namespace sscs.init uninstallService(); installService(); startService(); + CredMgr.Install(); return; } else if (opt != null && opt.ToLower () == "/uninstall") { stopService(); uninstallService(); + CredMgr.Uninstall(); return; } diff --git a/c_micasad/micasad.csproj b/c_micasad/micasad.csproj index 1b9ca07f..35202cc6 100644 --- a/c_micasad/micasad.csproj +++ b/c_micasad/micasad.csproj @@ -253,6 +253,11 @@ SubType = "Code" BuildAction = "Compile" /> +