Hi,
We have an internal app that allows users to access the app using their domain credentials or access the app by logging in through a web form.
Here is the back story. Any employee who belongs to one of two user groupps in our AD can access the app either to make changes to the app (Modify right) or just view the app (Read only right).
There are also some interns or temp employees who are being asked to access the app to either make changes or review some items on the app.
Since these interns and temp employees do not belong to our Active Directory, we are asked to create a login form to allow the users to log in.
Here is what we are having problems with: If a user has AD account, when s/he logs into the system, his/her name is display on the app with his/her access type.
Example, if John Doe who has Modify right logs in, the form displays his information as:
Current User: John Doe Access: Modify
This works fine. However, if an intern or temp employee who is not in our AD, his/her name is not being displayed on the form like above example.
Is there a way to manipute my code below so when an intern or temp employee logs in, his/her information is displayed on the form?
Login.aspx: This is where interns or temp employees login
After successful login, the user is redirected to portal.aspx page and this is where user's information described above is displayed.
I think my issue lies in Function GetUserFullName ()
Session("fullname"} = StrConv(dr("firstName") + " " + StrConv(dr("lastName"), vbProperCase)
Dim b As String() = Name.Split(","c)
Name = b(1) & " " & b(0)
f b is not null Then
Name = b(1) & " " & b(0)
Else
Name = Session("fullname"}
This way, whatever the value of Name will always show up on portal.aspx.
So far, I am not able to make it work
Public Shared Function getUserFullName() As String
Try
Dim wi As System.Security.Principal.WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent()
Dim a As String() = visitorIdentity.Split("\"c)
Dim ADEntry As System.DirectoryServices.DirectoryEntry = New System.DirectoryServices.DirectoryEntry("WinNT://" & a(0) & "/" & a(1))
Dim Name As String = ADEntry.Properties("FullName").Value.ToString()
visitorIdentity = a(1)
Dim b As String() = Name.Split(","c)
If b is not null Then
Name = b(1) & " " & b(0)
Else
Name = Session("fullname"}
End If
Return Name
Catch
Return "Unknown User"
End Try
End Function
Public Shared Sub loadUserInformation(ByVal ident As String, ByVal ip As String, ByVal system As String)
visitorIdentity = ident
visitorIPAddress = ip
visitorSystem = system
visitorFullName = getUserFullName()
End Sub
Thank you in advance
This code came from your forum. Awesome code.