Results 1 to 6 of 6

Thread: user identity: string check??

  1. #1

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

    user identity: string check??

    Hi,

    I my application I want to hide certain menu options depending on the user that uses the application. My idea was to create a database with all the users and their specific rights and then check in the application which user is current.

    Retracing the user can be done by:

    Dim UserIdentity As WindowsIdentity = WindowsIdentity.GetCurrent

    but this gives the username and the name of the machine he is working on (ex: tb/PC001). I just need the part before the /. Is there a way to get this or do I have to write a function to decompose the returned string?

    Can somebody give me a help with this function because I don't know how to code this.

    thanx,

    Tom

  2. #2
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    one dirty way to solve it is just use

    dim foobar as string = "abc\def"

    dim result(2) as string = foobar.Split(CChar("\"))

    then you have the result(0) position as the first item..



    of yourse you can solve it by using substring and indexof (methods of the string class)


    yours
    Henrik

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2003
    Location
    Europe, Belgium
    Posts
    84
    thanks Mr. North

    I tried the following:


    Protected Sub checkuser()

    Dim UserIdentity As WindowsIdentity = WindowsIdentity.GetCurrent

    Dim foobar As String = UserIdentity.Name

    Dim result(2) As String = foobar.Split(CChar("\"))
    End Sub


    But I get the following erro at result(2) : explicit initialisation is not permitted for arrays declared with explicit bounds.

    Any idea??

    TOmf

  4. #4
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    oh sorry.. I wrote that completly from heart... forgot one small detail... you can't explicit set bounds if you do like that, you have to make it "un-dimmed":

    dim result() as string = test.split(cchar("\"))

    that should work.

    yours Henrik

  5. #5

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

    I know I'm a newbie.

    Tom

  6. #6
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    Everyone is a newbie in the beginning

    yours
    Henrik

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