VB.net 2013 - Windows Forms using Membership Validation

OK, this seems simple...but I can't seem to figure it out!

I'm using the AspNetSqlMembershipProvider in my windows form...which works great to login in:
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        If Membership.ValidateUser(UsernameTextBox.Text, PasswordTextBox.Text) Then
            Me.Close()
            frm_Lookup.Show()
        Else
            MessageBox.Show("Your login attempt was not successful. Please try again.", "Login", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
    End Sub

Once I open the Lookup form based on the fact that their login passed the validation...how do I get the current user name?
For example in ASP.net I can use User.Identity.Name, but what is it in Windows Forms?

Thanks,
Mark
smithmrkAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lokesh B RDeveloperCommented:
Hi,

try this

Imports System.Security.Principal
Imports System.Web.Security

Open in new window


Dim name As String =  Thread.CurrentPrincipal.Identity.Name
Dim user As MembershipUser = Membership.GetUser(name)
Dim userName As String = user.UserName

Open in new window

smithmrkAuthor Commented:
I tried this:

Thread.CurrentPrincipal.Identity.Name

and it picks up my laptop domain user name...NOT the SQL ASP Membership Provider user name.
I log into my companies domain...however the database (Membership Provider) that I use for my application is different and I'm NOT picking up those user names from: Thread.CurrentPrincipal.Identity.Name

Thanks,
Mark
CodeCruiserCommented:
Can you not store the username, that has been provided to you when logging in, somewhere?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smithmrkAuthor Commented:
Yes, I was just hoping I could access it the same way I do with ASP.net.

Thanks,
Mark
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.