Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Any suggestions regarding default login
Sat, Oct 6 2012 3:18 AMPermanent Link

IQA

Hi All,

I'm wondering if anyone else has had this situation and how they got
around it.

In a client / server app, the server creates the database and default
users. Obviously I have to use the default Administrator / password in
the session to do this.

My question is, after the initial setup I don't want the server to use
the default USER, but the thing is, my server app on running, checks the
database / users exist and if not creates them.

So the question is, how can my server know if its to use the default
USER to login OR the one it creates after the installation without being
able to first get to the Configuration.Users / Database information to
check?

I was thinking about storing a flag in the registry, but then I can see
a user uninstalling the program and somehow the registry flag doesn't
get removed even though I set it to in the uninstaller.

Has anyone else had a similar situation? Maybe there a perfectly simple
solution and I'm thinking in the box.

Thanks,

Phil.
Sat, Oct 6 2012 5:08 AMPermanent Link

Uli Becker

Phil,

> My question is, after the initial setup I don't want the server to use
> the default USER, but the thing is, my server app on running, checks the
> database / users exist and if not creates them.
>
> So the question is, how can my server know if its to use the default
> USER to login OR the one it creates after the installation without being
> able to first get to the Configuration.Users / Database information to
> check?

How about doing it like this:

1. For the initial setup use the default password.
2. After the setup remove the default username and default password from
your main session.
3. Now the Session.OnLogin event will fire

From the help file:
<<
The OnLogin event is fired when the session is connected and the
LoginUser and LoginPassword
properties have not been assigned or have been assigned but are not
valid. You can specify the user
name and password via the UserName and Password parameters. The Continue
parameter indicates
whether the connection process should continue or whether the session
should stop trying to connect.
>>

4. Within this event you can get any information from your database by
using a second session and either refuse the connection, create a new
user and so on.

Uli
Sat, Oct 6 2012 6:13 AMPermanent Link

IQA

> How about doing it like this:
>
> 1. For the initial setup use the default password.
> 2. After the setup remove the default username and default password from
> your main session.
> 3. Now the Session.OnLogin event will fire
>
>  From the help file:
> <<
> The OnLogin event is fired when the session is connected and the
> LoginUser and LoginPassword
> properties have not been assigned or have been assigned but are not
> valid. You can specify the user
> name and password via the UserName and Password parameters. The Continue
> parameter indicates
> whether the connection process should continue or whether the session
> should stop trying to connect.
>  >>
>
> 4. Within this event you can get any information from your database by
> using a second session and either refuse the connection, create a new
> user and so on.
>
> Uli
>

Cheers Uli, as always a very useful solution... I did come up with a
function that uses 2 try / catch statements to determine if either of
the USERS exist as the session is connected and return a result of
either default, live or none.


int __fastcall TForm1::CheckServerUser(void)
{
  bool CDSUserfound;
  int UserMode;

  // set session to LIVE login
  mySession->LoginUser = "liveuser";
  mySession->LoginPassword = "livepassword";

  try
  {
    mySession->Connected = true;
    mySession->Connected = false;

    UserMode = ltLive;
    CDSUserfound = true;

  }
  catch(...)
  {
    CDSUserfound = false;
  }

  if (!CDSUserfound)
  {
    mySession->LoginUser = "Administrator";
    mySession->LoginPassword = "EDBDefault";

    try
    {
      mySession->Connected = true;
      mySession->Connected = false;

      UserMode = ltDefault;
    }
    catch(...)
    {
      UserMode = ltNone;
    }
  }

  return UserMode;
}
//---------------------------------------------------------------------------
Image