Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

ASP-Sharepoint Windows user problem

  Asked By: Ricardo    Date: Jan 24    Category: Sharepoint    Views: 874

encountered a pproblem, is it possible to get the username of the
user logged into windows using asp?

uh, we have a sharepoint portal and a webpart that accesses an ASP
site.. we need to allow users to access the ASP page but with
restriction depending on who is the user... but we do not want to let
the user log on again, we just need to know who the user is...

is that doable in ASP? java/vbscript?



2 Answers Found

Answer #1    Answered By: Marc Dixon     Answered On: Jan 24

Yes this is doable there is a sample web part located at
http://www.sharepointcode.com under web parts it is entitled username.dwp. It
should give you the information you need to be able to get the username  of the
user logged  into the system. You will need to write your own code to validate
them against something. But it should give you a good starting point.

Answer #2    Answered By: Johathan Mcgowan     Answered On: Jan 24

You can validate a windows  user in .NET as follows. Same can be used in asp  by
writing a component for windows login validation

Imports System.DirectoryServices

Public Function ValidateUser(ByVal strDomainAndUsername As String, ByVal strUser
As String, ByVal strPassword As String)

'Dim domainAndUsername As String = strDomain & "\" & strUserName

Dim entry As DirectoryEntry = New DirectoryEntry(_path,
strDomainAndUsername, strPassword)


'Bind to the native AdsObject to force authentication.

Dim obj As Object = entry.NativeObject

Dim search As DirectorySearcher = New DirectorySearcher(entry)

search.Filter = "(SAMAccountName=" & strUser & ")"


Dim result As SearchResult = search.FindOne()

If (result Is Nothing) Then

Session.Add("Validation", "False")

Return False

End If

Catch ex As Exception

Session.Add("Validation", "False")

Return False

End Try

Session.Add("Validation", "True")

Return True

End Function

Didn't find what you were looking for? Find more on ASP-Sharepoint Windows user problem Or get search suggestion and latest updates.