28.12.2013 Views

Building Secure ASP.NET Applications - People Search Directory

Building Secure ASP.NET Applications - People Search Directory

Building Secure ASP.NET Applications - People Search Directory

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

340<br />

<strong>Building</strong> <strong>Secure</strong> <strong>ASP</strong>.<strong>NET</strong> <strong>Applications</strong><br />

}<br />

[WebMethod]<br />

public string GetHttpContextUserIdentity()<br />

{<br />

return HttpContext.Current.User.Identity.Name;<br />

}<br />

More Information<br />

● For a list of all security related Knowledge Base articles<br />

● For a list of security related articles that deal with frequently seen error messages,<br />

use the following link go to the Microsoft Knowledge Base and use the<br />

following search keywords:<br />

prb kbsecurity kbaspnet<br />

Determining Identity in a Visual Basic 6 COM Object<br />

The following method can be used to return the identity of a Visual Basic 6 COM<br />

object. You can call Visual Basic 6.0 COM objects directly from <strong>ASP</strong>.<strong>NET</strong> applications<br />

through COM interop. The following method can be helpful when you need to<br />

troubleshoot access denied errors from your component when it attempts to access<br />

resources.<br />

Private Declare Function GetUserName Lib "advapi32.dll" _<br />

Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long<br />

Public Function WhoAmI()<br />

Dim sBuff As String<br />

Dim lConst As Long<br />

Dim lRet As Long<br />

Dim sName As String<br />

lConst = 199<br />

sBuff = Space$(200)<br />

lRet = GetUserName(sBuff, lConst)<br />

WhoAmI = Trim$(Left$(sBuff, lConst))<br />

End Function<br />

.<strong>NET</strong> Remoting<br />

If a remote object is hosted in <strong>ASP</strong>.<strong>NET</strong>, and is configured for Windows<br />

authentication, you must specify the credentials to be used for authentication<br />

through the credentials property of the channel. If you do not explicitly set<br />

credentials, the remote object is called without any credentials. If Windows<br />

authentication is required, this will result in an HTTP status 401, access denied<br />

response.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!