How to obtain current credentials?

  • Thread starter Thread starter K Viltersten
  • Start date Start date
K

K Viltersten

According to the example at the following
location, i should use the following code
in order to obtain the current credentials.

Link:
http://msdn.microsoft.com/en-us/lib...sauthenticationconfiguration.credentials.aspx

Code:
FormsAuthenticationCredentials currentCredentials =
formsAuthentication.Credentials;

However, the "formsAuthentication" seems
not to be declared or detected. What is
missing on the site (alternatively, what
did i miss to realize)?!

Regards
Konrad Viltersten
 
try this:
Imports System.Security.Principal

Public Function currentId() As String
Dim strReturn As String

strReturn = WindowsIdentity.GetCurrent().Name()

'strReturn = User.Identity.Name

Return strReturn

End Function
 
try this:
Imports System.Security.Principal

Public Function currentId() As String
Dim strReturn As String

strReturn = WindowsIdentity.GetCurrent().Name()

'strReturn = User.Identity.Name

Return strReturn

End Function

How would you express the same hint in C#?

Regards
Konrad Viltersten
 
How would you express the same hint in C#?
using System.Security.Principal;

// ...then, within a class...

public string CurrentId()
{
return WindowsIdentity.GetCurrent().Name;
}

Thanks. I should have thought of it myself... :)

Regards
Konrad Viltersten
 
Back
Top