Results 1 to 9 of 9

Thread: [RESOLVED] How to set user permissions from program

  1. #1

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Resolved [RESOLVED] How to set user permissions from program

    Alright so I realized something I would like to change. How can I show the admin settings forms only if the computer user account is Admin otherwise those settings or even the buttons aren't shown but are active as the admin sets them?

  2. #2

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: How to set user permissions from program

    Fixed. I just add a login screen and if the username and password belongs to the textfiles that contain the admin username and passwords then the settings button is visible otherwise it isn't and the user name and password is filtered through the regular user text files (one for password and one for username Basically if user and pass match of the reg user crediental files then user permssions set and if admin admin is set)
    If you would like me to post code I certainly can

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: [RESOLVED] How to set user permissions from program

    I marked this thread as Resolved since you obviously solved it in a manner that you're happy with.

  4. #4

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    My Easy Login Basic

    So I finally discovered a easy way, to create a login without using databases or anything other than a couple of text files.
    First things first create your project and add a login form, the way I do it is on load the form1 isn't visible until you login I am sure there is a better way but that is the way it works for me anyways once you have the login form add two text files name one Username and the other Password.

    Then go to your project settings and add two for the first name it username and second one name it password set the value for the username as
    Code:
    ..\..\UserName.txt
    And for the password setting as this:

    Code:
    ..\..\password.txt
    Now when the user enters the username and password and clicks ok this happens
    Code:
     For Each username As String In File.ReadLines(My.Application.Info.DirectoryPath & "\" & My.Settings.Username)
                    For Each password As String In File.ReadLines(My.Application.Info.DirectoryPath & "\" & My.Settings.Password)
        If UsernameTextBox.Text = username And PasswordTextBox.Text = password Then
                             form1.Visible = True
                                    Me.Visible = False
                     
                                    UsernameTextBox.Enabled = False
                                    PasswordTextBox.Enabled = False
                            else 
    msgbox("Incorrect login)
    end if 
    next 
    next
    I added some more custom stuff so if it is error shows retry option but that is causing a problem so don't wanna plague you with code that doesnt work lol.

    And dont forget to hide your form1 as
    Code:
     on load add this: me.visible = false
    Hope this helps someone!

  5. #5

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: My Easy Login Basic

    Oh and one last thing only reason i am posting this is because I asked about a basic login a while ago and just stumpled onto this myself and thought i would share it I use the same for each line idea for my filter part of my browser and thought well if it is trying to match it then maybe i can use it for a login too

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: [RESOLVED] How to set user permissions from program

    New thread merged with the old.

  7. #7

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,168

    Re: [RESOLVED] How to set user permissions from program

    Quote Originally Posted by Joacim Andersson View Post
    New thread merged with the old.
    There was a thread older than this i had asked about a login.

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: [RESOLVED] How to set user permissions from program

    OK, but it also fits here since you've solved the other issue related to this here. I just didn't think it required its own thread with some explanation without any kind of context, that's why I merged the threads.

  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: [RESOLVED] How to set user permissions from program

    But for completeness sake, here's a link to your original question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width