Sunday, August 2, 2009

Active Directory. How can I get the user id?

Everybody in my office signs on to their computers using an active directory name and password.





Yet on my virtual server (with account on active directory) my .net c# application fails.





I have tried everything. I can't even get their user id using the many different combinations of identity, servervariables etc from LDAP.





Setting windows authentication fails, setting anonymous won't give me their user id with any type of request.





I have tried all of the logical methods and settings in the web.config, impersonate=true, impersonate=false. When I use anonymous login, I can't get any information about them. If I use windows integrated login it fails or a login dialog box pops up requesting username and password.





This is all on an intranet site.





Ironically, my coworker who uses Coldfusion, has no problem getting information from LDAP and detecting userid.





What could be wrong?

Active Directory. How can I get the user id?
It's been awhile since I have scripted against Active Directory, but when I used to do that I usually coded in VBScript. I think if you write a simple VB Script to talk to AD and it works from your Virtual Server then this will give you the basics of what you need in your C# script and it will let you know if it is possible or not from your Virtual Server. One reason I used VBScript was because there are lots of good examples of VBscript talking to Active Directory on Google plus you can practically cut and paste them and then change a few lines and they will work. So when you get a VBscript to work from your Virtual Server, you will then know what connection parameters are needed. Here are a few examples of VBscript source I found using Google with examples of talking to AD: http://www.computerperformance.co.uk/vbs...


http://www.cruto.com/resources/vbscript/...


http://www.computerperformance.co.uk/vbs...


No comments:

Post a Comment