473,804 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help...want to display full name from AD on my intranet

Hello all! I have been searching for what seems like days now on how
to have my users full name (ie. John Smith) to appear on my intranet
but can't seem to be able to find the correct asp code. I have the
users authenticate by IIS via AD. I found some code to pull the user
name but I really would like to pull the users full name.

Would someone be so kind as to share with me the code to do just that.
I need the complete code as I am not a programmer and can get very
confused. I would really appreciate it. Otherwise, I may just loose
my mind!

Thanks so much in advance!

Matt

Nov 19 '05 #1
6 1611
public string GetUserFullname FromAccount(str ing username)
{
DirectoryEntry entryRoot = new DirectoryEntry( "LDAP://RootDSE");
string domain = entryRoot.Prope rties["defaultNamingC ontext"][0] as
string;
DirectoryEntry searchRoot = new
DirectoryEntry( @"LDAP://"+domain,<ADUse rUsername>,<ADU serPassword>);
DirectorySearch er search = new DirectorySearch er(searchRoot);
search.Filter =
"(&(objectClass =user)(objectCa tegory=person)( sAMAccountName= "+username+"))" ;
search.Properti esToLoad.Add("s amaccountname") ;
search.Properti esToLoad.Add("c n");
search.Properti esToLoad.Add("d isplayName");

SearchResult result = search.FindOne( );

return result.GetDirec toryEntry().Pro perties["displayNam e"].Value as
string;
}

where <ADUserUsername > is the username of a user with search access in
AD
and <ADUserPassword > the password of that user.

The code takes the current domain.
Use it like this : GetUserFullname FromAccount("us ername");

Nov 19 '05 #2
Try Tasos advice and hat should do the trick.
If you need more help POST it
Pstrick
<wa*********@ya hoo.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Hello all! I have been searching for what seems like days now on how
to have my users full name (ie. John Smith) to appear on my intranet
but can't seem to be able to find the correct asp code. I have the
users authenticate by IIS via AD. I found some code to pull the user
name but I really would like to pull the users full name.

Would someone be so kind as to share with me the code to do just that.
I need the complete code as I am not a programmer and can get very
confused. I would really appreciate it. Otherwise, I may just loose
my mind!

Thanks so much in advance!

Matt

Nov 19 '05 #3
Thanks for your assistance! But I am a little confused. I cut and
pasted the code into my asp page and now I get this error:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/test.asp, line 13

public string GetUserFullname FromAccount(str ing username)

I pasted the code in between the two "<% %>, I think this is correct?
Right?

Also...were it reads "<ADUserUsernam e> is the username of a with search
access", do I replace it with someone who has admin access to AD? and
does it have to read like this <admin> or just "admin"?

Use it like this : GetUserFullname FromAccount("us ername"); - I'm not
sure what you mean for me to do with this line.

Thanks again for your patiences and assistance.

Matt

Nov 19 '05 #4
Matt:

No, only the call, GetUserFullname FromAccount("us ername"), should be between
the "<% %>" tag.

The other should be declared either in your vb code or included as vbscript.

Venki

"wa*********@ya hoo.com" wrote:
Thanks for your assistance! But I am a little confused. I cut and
pasted the code into my asp page and now I get this error:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/test.asp, line 13

public string GetUserFullname FromAccount(str ing username)

I pasted the code in between the two "<% %>, I think this is correct?
Right?

Also...were it reads "<ADUserUsernam e> is the username of a with search
access", do I replace it with someone who has admin access to AD? and
does it have to read like this <admin> or just "admin"?

Use it like this : GetUserFullname FromAccount("us ername"); - I'm not
sure what you mean for me to do with this line.

Thanks again for your patiences and assistance.

Matt

Nov 19 '05 #5
Thanks Venki. But I still can't get the script to work correctly.
Could someone please cut and paste the exact code for the ASP page.

Thanks again.

Matt

Nov 19 '05 #6
Here comes a late answer :)

This is CSharp code... From the error message you are posting I suspect
that you try to use the script inside an old-fashioned ASP page,
something that will never work.

You need an ASP.NET page in CSharp or put this in an assembly that you
will call from your page ...

the ADUserUsername and ADUserPassword are the username/password of a
user with SEARCH rights in the Active Directory Catalog because ASPNET
default user does not have this kind of access.

Nov 19 '05 #7

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

Similar topics

4
1484
by: Joseph | last post by:
The idea is to show only one of the <Baby_Div> while hiding all the others. At the moment all I have managed to do is to show each <Baby_Div> in turn as expected, but the problem is that once a <Baby_Div>.innerHTML is replaced by one of the procedures, it does not work anymore, ie, the <Baby_Div> content is not displayed anymore, once code replaces the actual 'Blah' string. Structure: <Top-Div> <Child_Div (6 in total)> <Baby_Span>
1
1340
by: norwich | last post by:
Hi, I'm trying to display customer details on screen from a file using functions. The details are written to the file first then I display them on screen after I search for the file. My problem is this:
23
3296
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
0
1105
by: Tim::.. | last post by:
I have a datagrid that displays a list of contacts on our intranet site using the ActiveDirectory as it's main Data Source. I want to be able to show an image of each employee using a popup layer but am not sure how I match the Active Directory Data to the correct image stored in an SQL database. I plan on using the users fullname or email address as an identifier to match up the image with the correct user but really don't know how to...
9
15766
by: Robert Porter | last post by:
I have been experimenting with the Screen object. It has a property called Screen.DeviceName which returns a string value similar to the following: \\.\DISPLAY1 or \\.\DISPLAY2 I have 2 questions. When I assign the value to a class property and then serialize that class using a SoapFormatter I get a bunch of garbage characters after the name. Console.Writeline does not display these characters, but it does show a " in front of the...
1
9666
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
4
1925
by: _Raven | last post by:
Okay, I am playing with submitting forms with Ajax. I am trying to adapt this script to my forms: http://www.captain.at/howto-ajax-form-post-get.php I have included my code at the bottom of this post. Basically, this will work correctly if I remove all non-form related tags from the form =eg span, div, but I want to format the form all pretty like so??? Right now, it only collects 2 parts of the form fields =sites &
0
1194
by: r_o | last post by:
hi i dunno if this is the right forum to post this , but i couldn't find any other alternative so here it goes i'm using MS index server on a winXP machine to deliver a small search engine for an intranet(with ASP of course),nothing fancy. Now everything worked just fine . My problem is with the hit highlighting feature: the index server allows you to display a summary or a full hit-highlighted version of the document where the search...
0
1911
by: magicofureyes | last post by:
Hello Guys im a just a new user and i dnt knw much abt Xml i want to upload a new template in Blogger so got some free coding but when i save this code in Blogger template it say '''' Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly. XML error message: The element type "Variable" must be terminated by the matching end-tag "". so please help me out and check this coding if...
0
9715
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
10600
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10352
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...
1
7642
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
5535
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4313
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
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
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.