Results 1 to 9 of 9

Thread: How to detect a specific user

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Location
    Europe, Belgium
    Posts
    84

    Talking How to detect a specific user

    Hi,

    I'm trying to write a vb.net program with an access database (access 2000). The database will be installed on a server and the application itself should be installed on the desktop of every user. The users make all part of the same corporate LAN.

    The application will have a number of forms, but not every user should be able to use every function (or form). Is it possible to disable certain menu-functions based on the identification of the user? If yes, is there anybody who can help me with finding code to accomplish this?

    Thanks very much

    Tom

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    How you authenticate the users of your program (if you do at all)? And what is the basis of their rights?
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Location
    Europe, Belgium
    Posts
    84
    Well,

    I was thinking to create a database with all the usernames and their corresponding rights in it. So if a certain user wants to use the application, I first should have to check his corresponding rights after the application has detected his username.

    Or should i use another method?

    I dont know if this is possible but I would appreciate if you would give me some hints.

    Thanks

    Tom

  4. #4
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Thats a good Idea. You may also apply some methods to strengthen your authentication, for example certain critical tasks maybe done by certain people from special computers in the network.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Location
    Europe, Belgium
    Posts
    84
    OK, so my idea is good. But I don't know how the write this code. How can an application detect a specific user?

    Any code ideas or snippits?

    Tom

  6. #6
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    After doin some initializations in your program, you show an authentication form and ask for username and password. Then check the user credentials wih the ones in your database. If the user authenticates show the subsequent forms based on her role. It is wise to store send the passwords encrypted.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  7. #7
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    you can get the identity of the user with the " System.Security.Principal namespace " ( WindowsIdenty )
    then you could use a Select Case " username " statement, to determine which features to allow the user to have available.
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Location
    Europe, Belgium
    Posts
    84
    Thanks everybody, problem solved.

    This is the working code:

    Dim UserIdentity As WindowsIdentity = WindowsIdentity.GetCurrent
    'wp = New system.Security.Principal.WindowsPrincipal(WindowsIdentity.GetCurrent())
    Me.TextBoxUser.Text = UserIdentity.Name

    Many thanks

  9. #9
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Alternatively you can use Active Directory for your application security if you want to. You can either attach roles or groups to each user via the name from the code listed OR you can just add the groups/roles directly to the user through AD and then just check for them in your application. You can get a WindowsPrincipal object from the WindowsIdentity object you have and call its IsInRole method to check for roles.

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