如何绕过Lotus Notes密码登录-JAVA代码 [英] how to bypass lotus notes password log in - JAVA code

查看:381
本文介绍了如何绕过Lotus Notes密码登录-JAVA代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我的代码工作得很好,除了我需要以某种方式绕过的一部分,因为这将是一项autosys工作.那一部分是登录到Lotus Notes(当我登录并且该应用程序仍在运行时);每次我的脚本运行时,都要求用户输入密码.我已经尝试过代码登录到我的帐户,但是它仍然对我不起作用,所以我想知道我还缺少什么?任何帮助将不胜感激!我的代码如下.即将完成.弹出窗口是我唯一的问题.下面的代码是可编译的,到目前为止可以正常运行.

My code works great so far, except for one part which I need to bypass somehow because this is going to be an autosys job. That one part is logging in to lotus notes (when I'm logged in and the app is still running); every time my script runs it requires the user to input his password. I've tried code to log in to my account but it still didn't work for me, so I was wondering what am I missing? Any help would be greatly appreciated! My code is below. It is very close to being finished. The popup is the only issue I have; the code below is compilable and runs just fine so far.

import java.io.IOException;

import java.util.*;

import javax.mail.*;
import javax.mail.Session;
import javax.mail.internet.*;
import javax.swing.JOptionPane;
import javax.activation.*;

import lotus.domino.*;
import lotus.notes.addins.util.DominoAddressBook;

public class SendEmail extends NotesThread {

    @SuppressWarnings("deprecation")
    public static void main(String [] args) throws AddressException, MessagingException {
        // runs the program, mainly runNotes()
        SendEmail e = new SendEmail();
        e.start();  
        //e.sendMail();
    }

    public void runNotes() {
        try {           
            // TODO: pop's up dialog box for user password to be input if password is in line 32 else its line 59
            // might be because I'm creating a new session each time the program is run?
            // this lets you retype the password as many times as you want until you got it correct (no password in argument, line 32)
            lotus.domino.Session s = NotesFactory.createSessionWithFullAccess();

            // configures so the password entered in the dialog box matches the password here (security check user)
            // lotus.domino.Session s = NotesFactory.createSession((String)null, "userID", "pass!");    

            String p = s.getPlatform();
            System.out.println("Platform: " + p);

            System.out.println("Username: " + s.getUserName());
            System.out.println("Server name: " + s.getServerName());

            // self explantory, set's up the email with the message, attachment, etc
            Database db = s.getDatabase(null, "C:\\Program Files (x86)\\IBM\\Lotus\\Notes\\Data\\names.nsf");
            Document doc = db.createDocument();

            doc.setSaveMessageOnSend(true);
            RichTextItem attachedFile = doc.createRichTextItem("Attachment");
            attachedFile.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "G-Man", "C:\\Users\\F400318\\Desktop\\testDB2.xlsx", "testDB");

            StringBuilder body = new StringBuilder();
            body.append("This email is a test!");

            doc.appendItemValue("\n\n");
            doc.appendItemValue("Body", body.toString());
            doc.appendItemValue("Subject", "Test E-Mail");
            doc.appendItemValue("Sent", "user@emailcompany.com");

            doc.send("user@emailcompany.com");

            System.out.println("Check email... it should have been sent");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

推荐答案

您的代码在哪里运行?在Domino服务器上,是从Notes客户端还是完全在Notes/Domino之外?

Where is your code running? On a Domino server, from a Notes client, or outside of Notes/Domino entirely?

createSessionWithFullAccess()方法假定代码正在服务器上运行,并且除非需要将密码作为参数createSessionWithFullAccess("password")传递,否则它将在需要时提示输入密码.

The createSessionWithFullAccess() method assumes the code is running on the server and it will prompt for the password when needed unless you pass the password as an argument createSessionWithFullAccess("password").

http://www- 12.lotus.com/ldd/doc/domino_notes/rnext/help6_designer.nsf/b3266a3c17f9bb7085256b870069c0a9/5a8f8afb89d617f785256c54004d9eb4?OpenDocument

*编辑*

从代码的外观来看,您正在尝试使用JOptionPane创建一个Swing应用程序,因此在Notes客户端中不必使用createSessionWithFullAccess().您可以只使用NotesFactory.createSession(),它将使用用户的Notes ID作为凭据.您可以考虑的另一种选择是,如果要从Notes代理调用代码,则可以将代理创建的会话传递给代码,而不是创建新的会话.

From the looks of your code, you're trying to create a Swing application with JOptionPane, so using createSessionWithFullAccess() isn't necessary from the Notes client. You could just use NotesFactory.createSession() and it will use the users's Notes ID for credentials. Another option you could consider is if you're calling your code from a Notes agent, then you could pass the Session created by the agent to your code instead of creating a new one.

这篇关于如何绕过Lotus Notes密码登录-JAVA代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆