How difficult is to get who is currently logged into the ASP.NET page when
using Active Directory?
The user's NT account is linked to Active Directory, so the web site would have to use
impersonation to be aware of the user's NT/AD account. If this is the case, the
NT account info is already attached to the HTTPApplication. You can get to the
account name with the following code:
CType(Application.User.Identity, System.Security.Principal.WindowsIdentity).Name
From there, if you want to get
the AD properties associated with that name, you can use:
System.DirectoryServices.DirectorySearcher
Be aware that AD is a
freeform cache of name-value pairs. If the directory is not expertly maintained,
it will be very difficult to get meaningful data 100% of the time.
from a solution provided by Keith Payne in Message #1038223
|