Havin the username show in a label

M

Michael Persaud

Hi

Im trying to have a label on a page with some text and the user name

Windows auth is on in web config
Integrated security
The username is a domain name

dim uname
uname = user.identity.name
Lbl1.text = "Welcome" & uname& "Some other text"

Please tell me what im doing wrong

and secondly i dont want to retreive the domain name just the username.


Thanks
MP
 
K

Ken Cox [Microsoft MVP]

Hi Michael,

Does the code below get what you need?

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim uname As String
Dim wi As System.Security.Principal.WindowsIdentity = _
System.Security.Principal.WindowsIdentity.GetCurrent
uname = Mid(wi.Name, InStr(wi.Name, "\") + 1)
Lbl1.Text = "Welcome " & uname & ". Some other text"
End Sub

Ken
MVP [ASP.NET]
 
M

Michael Persaud

Hi
thanks for the code
I have been using similar code but to no avail.
I placed the label on the webform and then added the code but im just
getting the label with text label in my web page
So im still looking for any help

MP


Ken Cox said:
Hi Michael,

Does the code below get what you need?

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim uname As String
Dim wi As System.Security.Principal.WindowsIdentity = _
System.Security.Principal.WindowsIdentity.GetCurrent
uname = Mid(wi.Name, InStr(wi.Name, "\") + 1)
Lbl1.Text = "Welcome " & uname & ". Some other text"
End Sub

Ken
MVP [ASP.NET]


Michael Persaud said:
Hi

Im trying to have a label on a page with some text and the user name

Windows auth is on in web config
Integrated security
The username is a domain name

dim uname
uname = user.identity.name
Lbl1.text = "Welcome" & uname& "Some other text"

Please tell me what im doing wrong

and secondly i dont want to retreive the domain name just the username.


Thanks
MP
 
K

Ken Cox [Microsoft MVP]

What happens when you put this in your web.config file?

<identity impersonate="true"/>
<authentication mode="Windows" />


Michael Persaud said:
Hi
thanks for the code
I have been using similar code but to no avail.
I placed the label on the webform and then added the code but im just
getting the label with text label in my web page
So im still looking for any help

MP


Ken Cox said:
Hi Michael,

Does the code below get what you need?

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim uname As String
Dim wi As System.Security.Principal.WindowsIdentity = _
System.Security.Principal.WindowsIdentity.GetCurrent
uname = Mid(wi.Name, InStr(wi.Name, "\") + 1)
Lbl1.Text = "Welcome " & uname & ". Some other text"
End Sub

Ken
MVP [ASP.NET]


Michael Persaud said:
Hi

Im trying to have a label on a page with some text and the user name

Windows auth is on in web config
Integrated security
The username is a domain name

dim uname
uname = user.identity.name
Lbl1.text = "Welcome" & uname& "Some other text"

Please tell me what im doing wrong

and secondly i dont want to retreive the domain name just the
username.


Thanks
MP
 
M

Michael Persaud

Yes i do have those settings
I have event tried placing an cmd button to try having it changed on click
but still nothing.

I placed that code and the cmdButton on a seperate page and it still doesnt
work still

I know it cant be this impossible.

Thanks
MP


Ken Cox said:
What happens when you put this in your web.config file?

<identity impersonate="true"/>
<authentication mode="Windows" />


Michael Persaud said:
Hi
thanks for the code
I have been using similar code but to no avail.
I placed the label on the webform and then added the code but im just
getting the label with text label in my web page
So im still looking for any help

MP


Ken Cox said:
Hi Michael,

Does the code below get what you need?

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim uname As String
Dim wi As System.Security.Principal.WindowsIdentity = _
System.Security.Principal.WindowsIdentity.GetCurrent
uname = Mid(wi.Name, InStr(wi.Name, "\") + 1)
Lbl1.Text = "Welcome " & uname & ". Some other text"
End Sub

Ken
MVP [ASP.NET]


Hi

Im trying to have a label on a page with some text and the user name

Windows auth is on in web config
Integrated security
The username is a domain name

dim uname
uname = user.identity.name
Lbl1.text = "Welcome" & uname& "Some other text"

Please tell me what im doing wrong

and secondly i dont want to retreive the domain name just the
username.


Thanks
MP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,091
Messages
2,570,604
Members
47,223
Latest member
smithjens316

Latest Threads

Top