I want to invoke a Java MBean from UC4.
I found the below link to call the MBean directly from UC4, but I do not see an option in UC4 to create a JMX Job (from New Objects).
https://docs.automic.com/documentation/WEBHELP/English/all/components/AE/10/All%20Guides/Content/ucaccm.htm
Any pointers or blogs on this could be really helpful.
Talk to your UC4 administrator. He/she needs to allow access to the agent from your UC4 client number. Also, he/she needs to update the variable object named UC_OBJECT_TEMPLATE to include JOBS.JMX.
UC_OBJECT_TEMPLATE exists in client 0000 and may also exist in the client where you are currently logged in. If it exists in your current client, JOBS.JMX will need to be added to the UC_OBJECT_TEMPLATE in your current client.
Related
I need to read a software license that is stored in a Registry key located under HKEY_CURRENT_USER.
I'm running in a service in the SYSTEM account, so I cannot read this key.
I discovered that this Registry key has an account in HKEY_USER, where I can read the information. But I need to find out the SID of the logged in user.
How do I find this from a service in Delphi?
Call LookupAccountName to get the SID belonging to a given username (and the domain it belongs to). ConvertSidToStringSid can be used to convert the SID to a String.
Alternatively use the Delphi Jedi Windows Security Code Library (JWSCL).
I have a windows service that works fine with my application on the admin user, once I log into a non-admin user I need this user to be able to start,stop, and check the status of the service. I have used advapi32.dll library to be able to do this, but using this I am required to have the name of the users and the name of the service, so I would have to run this program every time a new user is added. I need a way to allow the service to communicate to all users, even newer users created after the service has been installed.
I have been trying to figure it out a way to do this by using Installshield service settings during installation. There is one field that you can create permissions, the only problem is that this is done using SDDL and it looks like this: O:<[%USERDOMAIN]>G:BAD:(D;OICI;GA;;;BG)(A;OICI;GRGWGX;;;<[%USERDOMAIN]>)(A;OICI;GA;;;BA)S:ARAI(AU;SAFA;FA;;;WD)
Does anybody knows a method to do this or can guide me through the SDDL if this is posible?
Thanks
is it possible to retrieve service recovery options as shown in service property windows like (First failure, Second failure, Subsequent failure information) using wmi??
and also for the password of a user account for a particular service in wmi?
we cannot get any password related information from the wmi. and also we cannot get the recovery tab details (shows in services.msc ) . if we need to get recovery details we may use the advapi32.dll queryserviceconfig2().
How can I tell if the application my code is running in, is it in a service or an application? Why do I want to know this - I'm writing some code that is injected into the target application and that code has no way of knowing this information up front, so it has to work it out itself.
I cannot rely on any code being called from the service control manager, start, stop, or command line parameters.
I'm currently looking at GetConsoleWindow() which I hope will return NULL for a service (no console) and a window handle for any application (has a console). Not sure how valid this assumption is.
Any ideas for a better solution?
Search the current process id (GetCurrentProcessId) from the list of all running services (EnumServicesStatusEx)?
The assumption of GetConsoleWindow() is not valid.
It seems to me that you care about the context of your process more. Are you asking that if your program is running in service context or the user session? If so, use ProcessIdToSessionId() http://msdn.microsoft.com/en-us/library/aa382990%28v=VS.85%29.aspx to get your session id and you will know it.
Use WMI to query for Win32_Service instances where 'ProcessId=MyProcessid'. If there is no match, then your process is not a service.
Background on WMI app creation in C++ here.
For Windows Vista or later you can check the session id. Session 0 is reserved for services and non-interactive programs. User sessions start from 1.
Use OpenProcessToken to get the current process token. Then use CheckTokenMembership to see if the token includes the WinServiceSid well-known SID.
How to get the logged in user (interactive user) and machine name from window service in c#. When i try Environment and other class to get logged in user name it just returns NT AUTHORITY\SYSTEM from window service.
The service executes under the SYSTEM account, so that what you see in the Environment class. The machine name should not be a problem (see Gmoliv's comment). Services execute independently from whoever may be logged on: that's one of the main reasons to have them.
If you want to find out what users (yes, there may be more than one) may be logged on to your computer, you'll have to use raw Windows API's AFAIK. If you really want this, one way could be to iterate through desktops, open the named desktop, get the associated user of each desktop, and look up the account name of the user (which returns the account name on the local machine). If you only want the user which may see something on screen, use OpenInputDesktop to get a handle instead of iterating through all of them.
Note that this requires your service to have higher access rights than usual. I'd be a bit suspicious of such a service myself.
Try this code snippet
ManagementScope ms = new ManagementScope(#"\\.\root\cimv2");
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_ComputerSystem");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(ms, query);
foreach(ManagementObject mo in searcher.Get())
{
Console.WriteLine(mo["UserName"].ToString());
}
Simplest approach (at least, using Visual Studio 2017 Community Edition and .Net Framework 4.7) --
Namespace: System.Security.Principal
Code:
Console.WriteLine(WindowsIdentity.GetCurrent().Name);
The above will give you:
COMPUTERNAME\username
UPDATE
Yet another approach would be to use Environment as in--
Console.WriteLine(Environment.UserName);
which will yield logged-in user's username
and
Console.WriteLine(Environment.MachineName);
which will yield the computer's or machine's name