Announcement

Collapse
No announcement yet.

In Edit Fields screen check for Administrator username

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • In Edit Fields screen check for Administrator username

    Hello,

    Please advise on the following issue:

    In the installer, I have added an "Edit Fields" screen in which I want the user to enter the Administrator username, password and domain (if the user is a domain admin).

    What I would like to do is validate whether the admin username that was introduced is part of the Windows Administrators group or not.
    Is there a way to do this?

    I know that I can get the user's SID and check that the username exists on the system, but I want to check if that username is an actual Administrator.


    Another solution that I was thinking about is to integrate a Powershell code that verifies this. Is there a way to integrate and run a powershell code at run-time, like when pressing Next ?

    Thank you,
    Cosmin

  • #2
    Sure, if you have a command which you can use to validate a set of credentials, you can run this with File.Run() before the Screen.Next(). Make sure that you run the command hidden (Powershell will still show on the task bar), and that you send the output to a temporary text file, so you read it with TextFile.ReadToString() and search for the expected string.

    A second option would try to use the Active Directory actions plugin built by a customer. I did not use it yet, so I cannot tell if it has the required function to check if a user is an admin, but I suspect, if it is not available yet, for a donation, he can add this feature.

    Finally, if you are familiar with the Windows API calls for checking user accounts, you can build your own library or plugin and add it to the package, and use it as required. You find the plugin SDK linked in the forum.

    Ulrich

    Centauri's post regarding the AD plugin: https://forums.indigorose.com/forum/...authentication

    Comment


    • #3
      Hello Ulrich,

      I have a Powershell script that checks the whether the user is local admin or domain admin, and I have included this script in the installer and I want to run it before the installation using the File.Run() command that you suggested.
      The issue now is that I can't figure out how to call this script at run-time, since it was not installed yet.

      Do you have any ideas on how to call this script at run-time?
      Maybe use the 'Run-time Folder: Archive' from the File Properties?
      Or can I install the script earlier than the rest of the files so I can use it's path to run it?

      Thank you,
      Cosmin

      Comment


      • #4
        You can add the script as a Primer File.

        Ulrich

        Comment


        • #5
          Hello Ulrich,

          I was able to use the script as Primer File, but I return with yet another problem.

          After running the script as Primer File, I redirect the output to a file: file.txt
          Now I want to read from file.txt using the TextFile.ReadToString, which you also recommended, and I want to display it in a message to check it

          content = TextFile.ReadToString(SessionVar.Expand("%TempLaun chFolder%").."\\file.txt")
          Dialog.Message("Notice", content, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

          However, it seems that content read contains only 3 characters, when it should contain the following string: Administrator is a Local Administrator user -- which is also displayed in the file.txt
          Click image for larger version

Name:	suf.JPG
Views:	218
Size:	29.9 KB
ID:	305110

          Do you have ideas why this is happening? Why doesn't the command read the string correctly?

          Thank you,
          Cosmin

          Comment


          • #6
            The output from Powershell uses Unicode encoding, and you need to convert it to ANSI before it can be processed in the script.
            Example: https://forums.indigorose.com/forum/...042#post305042

            Ulrich

            Comment

            Working...
            X