Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Please help...want to display full name from AD on my intranet

Reply
Thread Tools

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

 
 
wantagofast@yahoo.com
Guest
Posts: n/a
 
      10-21-2005
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

 
Reply With Quote
 
 
 
 
Tasos Vogiatzoglou
Guest
Posts: n/a
 
      10-21-2005
public string GetUserFullnameFromAccount(string username)
{
DirectoryEntry entryRoot = new DirectoryEntry("LDAP://RootDSE");
string domain = entryRoot.Properties["defaultNamingContext"][0] as
string;
DirectoryEntry searchRoot = new
DirectoryEntry(@"LDAP://"+domain,<ADUserUsername>,<ADUserPassword>);
DirectorySearcher search = new DirectorySearcher(searchRoot);
search.Filter =
"(&(objectClass=user)(objectCategory=person)(sAMAc countName="+username+"))";
search.PropertiesToLoad.Add("samaccountname");
search.PropertiesToLoad.Add("cn");
search.PropertiesToLoad.Add("displayName");

SearchResult result = search.FindOne();

return result.GetDirectoryEntry().Properties["displayName"].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 : GetUserFullnameFromAccount("username");

 
Reply With Quote
 
 
 
 
Patrick.O.Ige
Guest
Posts: n/a
 
      10-21-2005
Try Tasos advice and hat should do the trick.
If you need more help POST it
Pstrick
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.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
>



 
Reply With Quote
 
wantagofast@yahoo.com
Guest
Posts: n/a
 
      10-21-2005
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 GetUserFullnameFromAccount(string username)

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

Also...were it reads "<ADUserUsername> 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 : GetUserFullnameFromAccount("username"); - I'm not
sure what you mean for me to do with this line.

Thanks again for your patiences and assistance.

Matt

 
Reply With Quote
 
=?Utf-8?B?dnZlbms=?=
Guest
Posts: n/a
 
      10-21-2005
Matt:

No, only the call, GetUserFullnameFromAccount("username"), should be between
the "<% %>" tag.

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

Venki

"(E-Mail Removed)" 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 GetUserFullnameFromAccount(string username)
>
> I pasted the code in between the two "<% %>, I think this is correct?
> Right?
>
> Also...were it reads "<ADUserUsername> 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 : GetUserFullnameFromAccount("username"); - I'm not
> sure what you mean for me to do with this line.
>
> Thanks again for your patiences and assistance.
>
> Matt
>
>

 
Reply With Quote
 
wantagofast@yahoo.com
Guest
Posts: n/a
 
      10-23-2005
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

 
Reply With Quote
 
Tasos Vogiatzoglou
Guest
Posts: n/a
 
      10-25-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to hide the full url of a website and only display the domain name? Nikron ASP .Net 6 05-31-2006 09:53 AM
can eclipse display full file name in editor tabs? www.cuden.com Java 1 01-16-2006 06:01 AM
Deploying .NET Security policy - Setting Local Intranet to Full Trust MOHR ASP .Net Security 0 09-21-2005 08:36 PM
name = name.substring(0, name.lastIndexOf('.')); Help please Jack-2 Javascript 3 12-24-2003 04:39 PM
Display username and hostname on Intranet Bob Lin ASP General 6 10-29-2003 02:24 PM



Advertisments