Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Windows Authentication getting given name from username with c#


Message #1 by "Dan Deffner" <ddeffner@a...> on Fri, 26 Apr 2002 15:28:23
Yes, that was it.  Thank you very much.

Thanks
Dan Deffner

-----Original Message-----
From: Montgomery, Aiden [mailto:Aiden.Montgomery@f...]
Sent: Monday, April 29, 2002 9:09 AM
To: ASPX_Professional
Subject: [aspx_professional] RE: Windows Authentication getting given
name from username with c#


Have you included a reference to it in the project?
Right click in the Project installer and add a new reference.
Then look for DirectoryServices in the list that comes up.

That will let you use it.

Aiden Montgomery

-----Original Message-----
From: Dan Deffner [mailto:ddeffner@a...]
Sent: 29 April 2002 14:56
To: ASPX_Professional
Subject: [aspx_professional] RE: Windows Authentication getting given
name from username with c#


Yes, that should work.  However my visual studio.net IDE does not seem to be
behaving.  When I use "using System.DirectoryServices"  it has no idea what
that is.  It just keeps asking if I am  missing an assembly. How does one
install a library, or is this some other anomaly.

Thanks
Dan Deffner

-----Original Message-----
From: Montgomery, Aiden [mailto:Aiden.Montgomery@f...]
Sent: Friday, April 26, 2002 9:30 AM
To: ASPX_Professional
Subject: [aspx_professional] RE: Windows Authentication getting given
name from username with c#


I do some interacting with an Active Directory in C#.

However I do not query the server.
I interface to it as an LDAP server and then retrieve a list of all the
users in on the server.

DNC = server IP

Although this says WinNT it is still able to access the AD.

		DirectoryEntry de = new DirectoryEntry();
///Create a directory entry
		de.Path = "WinNT://" + DNC;
///Point the directory entry at the WinNT Domain
		de.Children.SchemaFilter.Add("user");
///Filter out the users
		DirectoryEntry deg = new DirectoryEntry();
///Create a directory entry

That might give you something to look at

Aiden

-----Original Message-----
From: Dan Deffner [mailto:ddeffner@a...]
Sent: 26 April 2002 16:28
To: ASPX_Professional
Subject: [aspx_professional] Windows Authentication getting given name
from username with c#


Hello,

   I got quite the issue here.  With ASP 3.0 I had a web application that 
would use windows authentication. Normally the code would contain error 
checking to make sure that sFullUser is not " ", but for the purpose it 
suits, it doesn't really need it. This information was then split into 
parts using the InStr command and sent to Active Directory to get a 
friendly or given name to put on the forms.  I am trying to rewrite this 
with ASP.Net with c# and am quite frustrated.  

ASP code (removing html code and forms, just want to focus on code itself)

<%@ Language=VBScript %>
 
<%
sFullName = trim(Request.ServerVariables ("LOGON_USER"))

iPosition = InStr(sFullName, "\")
sUserDomain = Left(sFullName, iPosition - 1)
sUser = Mid(sFullName, iPosition + 1)

Set objUser = GetObject("WinNT://" & sDomain & "/" & sUser)

Response.Write objUser.FullName

%>

Using the c# command split, I can accomplish pretty mush the same thing, 
but I have no idea of how to get it to talk to Active Directory to resolve 
the name. I didn't see any posts on this and am wondering if anyone is 
trying to do this.

Thanks
Dan Deffner







  Return to Index