Recent

Author Topic: veryfing that user is admin and displaying authentication dialog in macOS  (Read 1722 times)

inferno

  • New Member
  • *
  • Posts: 34
Hi all,
I need to check if logged user is admin or not. I found this solution: https://www.tweaking4all.com/forums/topic/lazarus-macos-request-admin-authentication/ but cannot get it working with 64 bit target. The following linker error occurs:

Quote
Error: linker: Undefined symbols for architecture x86_64:
Error: linker:   "_AuthorizationCreate", referenced from:
Error: ld: symbol(s) not found for architecture x86_64
An error occurred while linking
Error: Error while linking

The problem is that AuthorizationCreate is not available on x86_64... Any idea how to fix it?

Best regards,
Inferno


« Last Edit: January 02, 2020, 11:01:15 pm by inferno »

inferno

  • New Member
  • *
  • Posts: 34
After some more digging I found the problem. The solution is described here: https://forum.lazarus.freepascal.org/index.php?topic=16587.0. It is necessary to add {$linkframework Security}.

The second question - how to determine what type of user is logged in - admin or not?

Best regards,
Inferno

winni

  • Hero Member
  • *****
  • Posts: 3197
Hi!

Try to write a file in /root/
If no error occurs you are root.
If an error happens you are a simple user.

Winni

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Try to write a file in /root/
If no error occurs you are root.
If an error happens you are a simple user.

/ is a read-only filesystem in Catalina, so even if that worked previously (I doubt it because there is no /root directory - at least in Mojave) it definitely will not work now.

winni

  • Hero Member
  • *****
  • Posts: 3197
Oops, wrong OS.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
This looks like what you want: https://developer.apple.com/documentation/collaboration/cbidentity/1423867-ismemberofgroup

Also see: /usr/local/share/fpcsrc/fpc-3.3.1/packages/cocoaint/src/collaboration/*

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Having thought about this a bit more, the question is whether you really need to know whether the user is an admin or not because the authentication dialog allows any administrator on the computer to authenticate, not just the logged in user.

 

TinyPortal © 2005-2018