public static String GetCurrentUser() { String upn = "No Session"; String sid = ""; List <MyDLPEP.ActiveSession> consoleSessions = null; List <MyDLPEP.LogonSession> logonSessions = null; try { consoleSessions = MyDLPEP.SessionUtils.EnumerateActiveSessionIds(); logonSessions = MyDLPEP.SessionUtils.GetLogonSessions(); //just debugging foreach (MyDLPEP.ActiveSession session in consoleSessions) { Logger.GetInstance().Debug("ConsoleSession: name=" + session.name + " domain=" + session.domain + " sessionId=" + session.sessionId); } foreach (MyDLPEP.LogonSession session in logonSessions) { Logger.GetInstance().Debug("LogonSession: " + session); } foreach (MyDLPEP.ActiveSession cSession in consoleSessions) { foreach (MyDLPEP.LogonSession lSession in logonSessions) { if (cSession.sessionId == lSession.sessionId && cSession.name == lSession.name) { upn = lSession.name + "@" + lSession.domain; sid = lSession.sid; } } } } catch (Exception e) { Logger.GetInstance().Error("GetUSer error:" + e); } if (sid != "") { Logger.GetInstance().Debug("Sid:" + sid); //Update secure printers for shared printers if (Configuration.PrinterMonitor) { PrinterController.getInstance().ListenPrinterConnections(sid); } } return(upn); }
private static void WorkerMethodShared(object state) { Logger.GetInstance().Debug("Started Printing for MyDLP printer: " + sharedPrinterName); PrintQueue pQueue = null; try { PrinterController controller = PrinterController.getInstance(); LocalPrintServer pServer = new LocalPrintServer(); PrintQueueCollection qCollection = pServer.GetPrintQueues(); foreach (PrintQueue q in qCollection) { //Find mathing non secure printer if (q.Name == sharedPrinterName) { pQueue = q; } } if (pQueue == null) { throw new Exception("Unable to find a matching non secure printer for mydlp printer: " + sharedPrinterName); } Logger.GetInstance().Debug("Adding print job on real printer: " + pQueue.Name + ", path:" + sharedXpsPath + ", sharedJobID:" + sharedJobId); if (WaitForFile(sharedXpsPath)) { pQueue.AddJob(sharedJobId, sharedXpsPath, false); Thread.Sleep(1000); Logger.GetInstance().Debug("Removing:" + sharedXpsPath); File.Delete(sharedXpsPath); Logger.GetInstance().Debug("Finished Printing"); } else { Logger.GetInstance().Debug("WorkerMethodShared WaitForFile failed for xps file"); } } catch (Exception e) { Logger.GetInstance().Error("WorkerMethodShared Exception" + e); if (e.InnerException != null) { Logger.GetInstance().Error(e.InnerException.Message + e.InnerException.StackTrace); } } }
private static void WorkerMethodLocal(object state) { Logger.GetInstance().Debug("Started Printing for MyDLP printer: " + localPrinterName); PrintQueue pQueue = null; try { PrinterController controller = PrinterController.getInstance(); if (controller.IsPrinterConnection(localPrinterName)) { //It will be printerd remotely //It is a network printer connection on local computer PrinterController.PrinterConnection connection = controller.GetPrinterConnection(localPrinterName); IPAddress[] addresslist = Dns.GetHostAddresses(connection.server); Logger.GetInstance().Debug("Initiating remote print remoteprinter: " + connection.name + " on server:" + connection.server + "of File:" + localXpsPath); SeapClient.InitiateRemotePrint(localJobId, connection.name, addresslist[0].ToString(), localXpsPath); } else { //It is a local printer LocalPrintServer pServer = new LocalPrintServer(); PrintQueueCollection qCollection = pServer.GetPrintQueues(); foreach (PrintQueue q in qCollection) { //Find mathing non secure printer if (PrinterController.GetSecurePrinterName(q.Name) == localPrinterName) { pQueue = q; } } if (pQueue == null) { throw new Exception("Unable to find a matching non secure printer for mydlp printer: " + localPrinterName); } Logger.GetInstance().Debug("Adding print job on real printer: " + pQueue.Name + ", path:" + localXpsPath + ", jobID:" + localJobId); if (WaitForFile(localXpsPath)) { pQueue.AddJob(localJobId, localXpsPath, false); Thread.Sleep(1000); Logger.GetInstance().Debug("Removing:" + localXpsPath); File.Delete(localXpsPath); File.Delete(metaPath); Logger.GetInstance().Debug("Finished Printing"); } else { Logger.GetInstance().Debug("WorkerMethodLocal WaitForFile failed for xps file"); } } } catch (Exception e) { Logger.GetInstance().Error("WorkerMethod Exception" + e); if (e.InnerException != null) { Logger.GetInstance().Error(e.InnerException.Message + e.InnerException.StackTrace); } } }