In T-SQL I can use SELECT SUSER_SNAME()
, is there something like that for Active Directory / LDAP?
The problem is that I have to access Active Directory in other domains via LDAP and the only way to do that (for some of the data I need) is by using the RUNAS command with the NETONLY option. This option allows the process to access local resources with one ID and network resources with another.
Yes, providing a Username and Password to the System.DirectoryServices.DirectoryEntry
object works for most objects, but not for all objects. So, for the rest of the objects, I have to use RUNAS /NETONLY -- and there appears to be no way for the running application ( .net , C# ) to know that it is running via RUNAS and no way for it to know what user it is running as -- only the local user is known to the application.
If I can send a query to AD via LDAP saying, "I don't know who I am or even what domain I'm in, so please tell me", then I can log it.
What would be really useful is if the SearchResultCollection
would report back context, but it doesn't.
What I have tried:
As specified in the question above.
The Enterprise Network Admins I've asked have been no help either.