Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
[no name] 2-Jul-22 12:46pm    
Seems to have the right number of buzz words:

LDAP Server & User Details | Greenview Data[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900