Thank you for your help, I have it working on my computer but if I try externally I am getting the error Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type 'System.DirectoryServices.AccountManagement.UserPrincipal'
Any ideas on this?
Imports System.Security
Imports System.Security.Principal.WindowsIdentity
Imports Microsoft.Win32
Imports System.DirectoryServices.AccountManagement
Imports System.DirectoryServices.AccountManagement.UserPrincipal
Imports System.Web.Hosting
Partial Class _Default
Inherits System.Web.UI.Page
Dim UserAccount As String
Dim test As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
test = Right(Request.ServerVariables("REMOTE_USER"), 5)
Dim userFullName As String = UserPrincipal.Current.DisplayName
EmployeeTextBox.Text = userFullName
ReportingPeriodTextBox.Text = Now.Year
End Sub
End Class.
MKozlowski
Member
500 Points
573 Posts
Re: How can I retrieve the users full name using LDAP?
Dec 15, 2011 01:32 PM|LINK
Thank you for your help, I have it working on my computer but if I try externally I am getting the error Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type 'System.DirectoryServices.AccountManagement.UserPrincipal'
Any ideas on this?
Imports System.Security Imports System.Security.Principal.WindowsIdentity Imports Microsoft.Win32 Imports System.DirectoryServices.AccountManagement Imports System.DirectoryServices.AccountManagement.UserPrincipal Imports System.Web.Hosting Partial Class _Default Inherits System.Web.UI.Page Dim UserAccount As String Dim test As String Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load test = Right(Request.ServerVariables("REMOTE_USER"), 5) Dim userFullName As String = UserPrincipal.Current.DisplayName EmployeeTextBox.Text = userFullName ReportingPeriodTextBox.Text = Now.Year End Sub End Class.