Conocer el usuario desde ASP.Net

23/10/2007 - 03:55 por Roberto Londono | Informe spam
Hola amigos bueno he estado trabajando por un largo rato en esto.
La idea poder tener el login del usuario que esta en ese sitio, pues mi web
aplication lo necesita. Muchas gracias desde ya por la ayuda.

Lo que he logrado hasta ahora .
En mi pagina de inicio tengo este codigo de vb

' On the .NET tab of the Add Reference dialog box, select Windows SharePoint
Services in the list of components, click Select, and then click OK.
Imports Microsoft.SharePoint

Imports Microsoft.SharePoint.WebControls 'Bring spcontrol
Imports Microsoft.SharePoint.SPMember ' Bring SPuser


Partial Public Class Login
Inherits System.Web.UI.Page




Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim siteCollection As SPSite = SPControl.GetContextSite(Context)
If siteCollection Is Nothing Then

TBLoginName.Text = " is null "

Else


Dim site As SPWeb = siteCollection.AllWebs("Site_Name")
Dim user As SPUser = site.AllUsers("User_Name")

Dim LoginName As String = user.LoginName

TBLoginName.Text = LoginName



End If



My


<?xml version="1.0"?>

<configuration>

<appSettings/>
<connectionStrings/>
<system.web>
<!--
<connectionStrings/>
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.

Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
<compilation debug="true" strict="false" explicit="true" />
<pages>
<namespaces>
<clear />
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.

<authentication mode="Windows"/>

<!--
<identity impersonate="true"/>
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly"
defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>

<authorization>
<allow users="?"/>
<allow users="*"/>
<!-- Allow all users -->

<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
</authorization>




</system.web>
</configuration>



Cuando lo trato de ejecutar debajo de sharpoint este no me trae nada
solamente el null. No se que problema tengo.
 

Preguntas similares