views:

1102

answers:

3

Hi,

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. :(

+1  A: 

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.");
}
Mark
+1  A: 

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.

Carlos
+1, excellent idea, I edited my answer to use the "names.nsf" database.
Mark
+1  A: 

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");
Ed Schembor