473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Request.ServerVariables("AUTH_USER")??

I'm new to aspnet with only limited experience with classic asp. Since
I'm on a domain and all users are authenticated. In the past using
classic asp I used request.servervariables("auth_user") to grab the
domain logon name of the user. Is there a better way or more detailed
way in aspnet? Like, instead of putting "mydomain\bobjones" into a
variable using request.servervariables("auth_user"), can I extract the
actual name "Bob Jones" from Active Directory?

Thanks,
Jim
Nov 19 '05 #1
4 4255
It was Tue, 07 Jun 2005 12:20:59 -0700 when Jim in Arizona wrote:
I'm new to aspnet with only limited experience with classic asp. Since
I'm on a domain and all users are authenticated. In the past using
classic asp I used request.servervariables("auth_user") to grab the
domain logon name of the user. Is there a better way or more detailed
way in aspnet? Like, instead of putting "mydomain\bobjones" into a
variable using request.servervariables("auth_user"), can I extract the
actual name "Bob Jones" from Active Directory?

Try to using LDAP queries to get all info you need from AD.

Ziemowit
msn:zi*******@hotmail.com
Nov 19 '05 #2
Ziemowit wrote:
It was Tue, 07 Jun 2005 12:20:59 -0700 when Jim in Arizona wrote:

I'm new to aspnet with only limited experience with classic asp. Since
I'm on a domain and all users are authenticated. In the past using
classic asp I used request.servervariables("auth_user") to grab the
domain logon name of the user. Is there a better way or more detailed
way in aspnet? Like, instead of putting "mydomain\bobjones" into a
variable using request.servervariables("auth_user"), can I extract the
actual name "Bob Jones" from Active Directory?


Try to using LDAP queries to get all info you need from AD.

Ziemowit
msn:zi*******@hotmail.com


You wouldn't happen to have a code example would you?
Nov 19 '05 #3
No problem, examples directly from my code with short comments:

public string GetDisplayName(string cn) //cn is unique for user
{
string FullName = "";
try
{
DirectoryEntry entry = new
DirectoryEntry("LDAP://server/DC=yourdomain,DC=com"); //path for
server that store AD, can be domain server
entry.AuthenticationType = AuthenticationTypes.ReadonlyServer; //we
want only readonly access
entry.Username = "username"; //if domain allow anonymous access
to AD application then these two rows are not required
entry.Password = "password"; //if not, then you will need domain
account to acces to AD server
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(cn="+cn+")";
search.PropertiesToLoad.Add("displayName"); //name of property to
load
SearchResult sr = search.FindOne();
if (sr != null)
{
FullName = sr.Properties["displayName"][0].ToString(); //read
property
}
search.Dispose();
entry.Dispose();
}
catch
{
}
return FullName; //thats all
}

You have to check if your application have access to AD server and
create domain account if required. To get info what LDAP paths should
be I suggest you to use LDAPBrowser - cool software for browsing LDAP.

I hope it helps

Ziemowit

Nov 19 '05 #4

"Ziemowit" <zi*******@wp.pl> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
No problem, examples directly from my code with short comments:

public string GetDisplayName(string cn) //cn is unique for user
{
string FullName = "";
try
{
DirectoryEntry entry = new
DirectoryEntry("LDAP://server/DC=yourdomain,DC=com"); //path for
server that store AD, can be domain server
entry.AuthenticationType = AuthenticationTypes.ReadonlyServer; //we
want only readonly access
entry.Username = "username"; //if domain allow anonymous access
to AD application then these two rows are not required
entry.Password = "password"; //if not, then you will need domain
account to acces to AD server
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(cn="+cn+")";
search.PropertiesToLoad.Add("displayName"); //name of property to
load
SearchResult sr = search.FindOne();
if (sr != null)
{
FullName = sr.Properties["displayName"][0].ToString(); //read
property
}
search.Dispose();
entry.Dispose();
}
catch
{
}
return FullName; //thats all
}

You have to check if your application have access to AD server and
create domain account if required. To get info what LDAP paths should
be I suggest you to use LDAPBrowser - cool software for browsing LDAP.

I hope it helps

Ziemowit


I'm a vb user and c# is a bit greek to me but I think I can adapt and
overcome. :)

Yesterday I went through the System.DirectoryServices.ActiveDirectory
namespace in hopes of finding something useful in there for my purposes and
after getting lost of a while, was unable to find anything to suit my
purpose. Oh well.

Thanks for the help. I'll put it to good use.

Jim
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ian Staines | last post by:
In asp the following code: Request.Servervarables("AUTH_USER") will return the header variable AUTH_USER In .NET the code Request.Servervariables("AUTH_USER") returns the server variable...
3
by: Jeff Cochran | last post by:
First time I've seen this and I'm not even sure where to look for the answer. An ASP page with only this code: <% Response.Write "User: " & Request.ServerVariables("LOGON_USER") %> On most...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.