Find the User Who's Currently Logged In
Find the User Who's Currently Logged In
Open Dental supports the idea of user authentication/identity (http://www.opendental.com/manual/security.html).
How do I programatically identify the currently "logged in" user to Open Dental? How does this behave when there's no authentication enabled in Open Dental?
E.G. Is there a Class/Method that I can call in OpenDentBusiness?
Thanks!
-Tyler
How do I programatically identify the currently "logged in" user to Open Dental? How does this behave when there's no authentication enabled in Open Dental?
E.G. Is there a Class/Method that I can call in OpenDentBusiness?
Thanks!
-Tyler
Re: Find the User Who's Currently Logged In
You can identify the currently logged in user from OpenDentBusiness.Security.CurUser. This is guaranteed to be set when running the Open Dental program. If you are not using authentication, the first Admin user with no password will be set as the current user.
Re: Find the User Who's Currently Logged In
Thanks Chris. Any way to tell whether Auth has been turned on for a given install?
I.E. If I call OpenDentBusiness.Security.CurUser, and I get the Admin user, how do I know the difference between someone logging in as Admin (with Auth ON), vs. everyone being an Admin (with Auth OFF).
I.E. If I call OpenDentBusiness.Security.CurUser, and I get the Admin user, how do I know the difference between someone logging in as Admin (with Auth ON), vs. everyone being an Admin (with Auth OFF).
Re: Find the User Who's Currently Logged In
Sure, you can call OpenDentBusiness.Userods.GetAdminUser. If the password on that user is blank, you can tell that everyone is logging in as the admin user.
Re: Find the User Who's Currently Logged In
Great, thanks Chris!
Re: Find the User Who's Currently Logged In
I am interested in the same information. I want to create a utility to nag users to punch in on the timeclock if they login but haven't punched in.
The following code returns null for user and the second line throws and exception about being unable to connect to any of the specified MySQL hosts. Apparently there is more that I need to know...
OD is running and I am logged in...
Thanks,
JLM
The following code returns null for user and the second line throws and exception about being unable to connect to any of the specified MySQL hosts. Apparently there is more that I need to know...
OD is running and I am logged in...
Thanks,
JLM
Code: Select all
namespace WindowsFormsApp5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Userod user = OpenDentBusiness.Security.CurUser;
Userod user2 = OpenDentBusiness.Userods.GetAdminUser();
}
}
}
Re: Find the User Who's Currently Logged In
All of those errors point to you not actually being logged into Open Dental yet. Maybe you launched your form too early? What plug-in hook are you using to launch your form with?JLM wrote:...The following code returns null for user and the second line throws and exception about being unable to connect to any of the specified MySQL hosts. Apparently there is more that I need to know...
OD is running and I am logged in...
The best thing about a boolean is even if you are wrong, you are only off by a bit.
Jason Salmon
Open Dental Software
http://www.opendental.com
Jason Salmon
Open Dental Software
http://www.opendental.com
Re: Find the User Who's Currently Logged In
I am logged in (DrM appears in window bar) and the application is launched with OD running. I don't use any hooks. The application is free standing. The code shown earlier is the complete application so far as I am testing the concept. There must be some initialization that I am missing.jsalmon wrote:All of those errors point to you not actually being logged into Open Dental yet. Maybe you launched your form too early? What plug-in hook are you using to launch your form with?JLM wrote:...The following code returns null for user and the second line throws and exception about being unable to connect to any of the specified MySQL hosts. Apparently there is more that I need to know...
OD is running and I am logged in...
JLM
Re: Find the User Who's Currently Logged In
You need to implement some sort of complicated Windows messaging system so the two "free standing" applications can talk to each other because how you are trying to user OpenDentBusiness isn't how applications talk to each other. You can't ask a standalone library (OpenDentBusiness.dll) who the currently logged in user is because the library doesn't have any context. The application (OpenDental.exe) has the context (memory and such) for what user is currently logged in and simply utilizes the library as blueprints if you will.
The easiest way to get this information is to convert your "free standing" application into a plug-in where you launch it from the ODToolBar in one of the main modules.
http://www.opendental.com/manual/plugins.html
The easiest way to get this information is to convert your "free standing" application into a plug-in where you launch it from the ODToolBar in one of the main modules.
http://www.opendental.com/manual/plugins.html
The best thing about a boolean is even if you are wrong, you are only off by a bit.
Jason Salmon
Open Dental Software
http://www.opendental.com
Jason Salmon
Open Dental Software
http://www.opendental.com
Re: Find the User Who's Currently Logged In
Actually, I have written code for other applications that 'expose themselves' in this exact fashion. They want utility writers to access the database through their interface instead of banging on the database yourself. It was a promising approach but not if I have to try to learn the plugin system. I will look at the db to see if I can determine who has punched in today and I can enumerate the windows and extract the user name from the window title to accomplish the same thing. Thanks for the info.
JLM
JLM
Re: Find the User Who's Currently Logged In
That is exactly what the OpenDentBusiness.dll is for and we encourage you to use it for interfacing with the DB.They want utility writers to access the database through their interface instead of banging on the database yourself.
Security.CurUser is not a database field though. That field needs the context of OpenDental in order to tell who is logged in because it is set by the OpenDental program as an in-memory variable.
I highly recommend using our plug-in system to utilize variables that are set within OpenDental.exe.
If you still wish to not use the plug-in system and instead use the method you proposed then I can foresee one pitfall with that...
What happens if you ran three instances of OpenDental and logged in to three different users?
Re: Find the User Who's Currently Logged In
What happens if you ran three instances of OpenDental and logged in to three different users?
![Laughing :lol:](./images/smilies/icon_lol.gif)
thanks for the info.
JLM