|
-
Dec 16th, 2003, 02:30 AM
#1
Thread Starter
Lively Member
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
-
Dec 16th, 2003, 02:42 AM
#2
Frenzied Member
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
-
Dec 16th, 2003, 03:01 AM
#3
Thread Starter
Lively Member
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
-
Dec 16th, 2003, 03:20 AM
#4
Frenzied Member
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
-
Dec 16th, 2003, 03:32 AM
#5
Thread Starter
Lively Member
thanks a lot,
I know I'm a newbie.
Tom
-
Dec 16th, 2003, 03:34 AM
#6
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|