Recent

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

inferno

  • New Member
  • *
  • Posts: 28
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: 28
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: 1814
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: 946
  • 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.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

winni

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

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 946
  • 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/*
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 946
  • 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.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

 

TinyPortal © 2005-2018