如何检查Lotus Notes配置的Domino服务器的名称?使用 C#

发布于 2024-08-05 19:03:43 字数 1126 浏览 7 评论 0原文

我正在尝试登录 Domino 服务器。 为此,我从用户处获取 Lotus Notes 密码和 Domino 服务器名称。

if (notesPassword == "" && serverName == "")

{

MessageBox.Show("请输入服务器名称!!");

返回;

}

else

{

   if (connectToDomino(notesPassword, serverName))

   {

      MessageBox.Show("Connection Established Succesfully!!..");

    }

   else

   {
    MessageBox.Show("Connection Fail.Please Login Again To Begin");

   }

}//else

公共 bool connectToDomino(string NotesPassword, string strDominoServerName)

{

       try

       {
           if (_lotesNotesSession == null)
           {

              NotesSession notesSession = new Domino.NotesSessionClass();

              notesSession.Initialize(NotesPassword);


             }
           return true;
       }
       catch(Exception ex)
       {
           return false;
       }

}

这里我正在初始化 Notes 密码。所以在本例中它只是验证 Notes 密码。 因此,即使用户输入无效的服务器名称条目,上述函数也会返回 true。

我尝试过:

string serverName =notesSession.ServerName;

但它显示空值。 :(

I am trying to login Domino server.
For that i am taking Lotus Notes Password and Domino Server Name from user.

if (notesPassword == "" && serverName == "")

{

MessageBox.Show("Please enter the server name !! ");

return;

}

else

{

   if (connectToDomino(notesPassword, serverName))

   {

      MessageBox.Show("Connection Established Succesfully!!..");

    }

   else

   {
    MessageBox.Show("Connection Fail.Please Login Again To Begin");

   }

}//else

and in

public bool connectToDomino(string NotesPassword, string strDominoServerName)

{

       try

       {
           if (_lotesNotesSession == null)
           {

              NotesSession notesSession = new Domino.NotesSessionClass();

              notesSession.Initialize(NotesPassword);


             }
           return true;
       }
       catch(Exception ex)
       {
           return false;
       }

}

Here i am initializing notes password.So in this case it is just verifying Notes Password.
So even if user enters invalid entry of server name above function will return true.

I tried :

string serverName = notesSession.ServerName;

But it is showing null value. :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

莫言歌 2024-08-12 19:03:43

您的目标是服务器上的特定数据库吗?

我不相信您可以仅检查服务器/数据库组合是否有效:

Domino.NotesSessionClass _lotesNotesSession = new Domino.NotesSessionClass();
//Initializing Lotus Notes Session
_lotesNotesSession.Initialize( "my_password" );
Domino.NotesDatabase _serverDatabase = _lotesNotesSession.GetDatabase( "some_server", "names.nsf", false );
if (_serverDatabase == null){
   System.Console.Writeline("Can not connect to server.");
}

Are you targeting a specific database on the server?

I do not believe you can check that the server is valid just that the server/database combination is:

Domino.NotesSessionClass _lotesNotesSession = new Domino.NotesSessionClass();
//Initializing Lotus Notes Session
_lotesNotesSession.Initialize( "my_password" );
Domino.NotesDatabase _serverDatabase = _lotesNotesSession.GetDatabase( "some_server", "names.nsf", false );
if (_serverDatabase == null){
   System.Console.Writeline("Can not connect to server.");
}
眼泪也成诗 2024-08-12 19:03:43

每个服务器都应该有一个名称.nsf 数据库,因此如果您使用 Mark 提到的技术并检查名称.nsf 数据库,那么它应该告诉您服务器是否有效。

希望这会有所帮助

也许如果您提供有关您尝试使用此功能的更多详细信息,我们可以帮助您找到更好的解决方案。

Every server should have a names.nsf database, so if you use the technique mentioned by Mark and check for the names.nsf database then it should tell you if the server is valid or not.

Hope this helps

Maybe if you give more details on what you are trying to use this for, we could help you find a better solution.

两仪 2024-08-12 19:03:43

由于名称.nsf 不一定需要存在于每个服务器上,因此更安全的方法是使用 NotesSession 的 getDbDirectory 方法。如果无法访问服务器,这应该引发异常。

Domino.DbDirectory = _lotesNotesSession.getDbDirectory ("server_name");

Since names.nsf does not necessarily need to exist on every server, a safer approach would be to use the getDbDirectory method of NotesSession. This should throw an exception if the server cannot be accessed.

Domino.DbDirectory = _lotesNotesSession.getDbDirectory ("server_name");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文