473,806 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Request.ServerV ariables("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.serverv ariables("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\bobjo nes" into a
variable using request.serverv ariables("auth_ user"), can I extract the
actual name "Bob Jones" from Active Directory?

Thanks,
Jim
Nov 19 '05 #1
4 4279
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.serverv ariables("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\bobjo nes" into a
variable using request.serverv ariables("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*******@h otmail.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.serverv ariables("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\bobjo nes" into a
variable using request.serverv ariables("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*******@h otmail.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,D C=com"); //path for
server that store AD, can be domain server
entry.Authentic ationType = AuthenticationT ypes.ReadonlySe rver; //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
DirectorySearch er search = new DirectorySearch er(entry);
search.Filter = "(cn="+cn+" )";
search.Properti esToLoad.Add("d isplayName"); //name of property to
load
SearchResult sr = search.FindOne( );
if (sr != null)
{
FullName = sr.Properties["displayNam e"][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.p l> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.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,D C=com"); //path for
server that store AD, can be domain server
entry.Authentic ationType = AuthenticationT ypes.ReadonlySe rver; //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
DirectorySearch er search = new DirectorySearch er(entry);
search.Filter = "(cn="+cn+" )";
search.Properti esToLoad.Add("d isplayName"); //name of property to
load
SearchResult sr = search.FindOne( );
if (sr != null)
{
FullName = sr.Properties["displayNam e"][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.Director yServices.Activ eDirectory
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
3204
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 AUTH_USER, but if you want the header variable you must request it with Request.Headers("AUTH_USER")
3
6814
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 systems returns the domain\userID for the user on the workstation, as expected. But I have one workstation (at least) where this returns the domain\ID of whatever account is logged into the web server.
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10371
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5683
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.