|
| |
|
|
willard31
Posts: 8 Joined: 11/10/2004 Status: offline
|
Connect to AD Global Catalog - 11/10/2004 12:12:45
Hi, in my web-based help desk app, we are selecting users from an Access database. I would like to connect the site to Active Directory's Global Catalog so that I could query that user data and I would no longer have to maintain the separate user table in Access. Any suggestions on how to accomplish this?
|
|
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: Connect to AD Global Catalog - 11/10/2004 12:30:18
Hi and Welcome to OutFront. I'm not sure about connecting directly to AD, but I use code like this: <%
DIM myUserName, myUserID, myDSN
myDSN = "DSN=XXXXXXX;uid=XX;pwd=XXXX;database=XXXX"
'Grab login name
MyVar=request.servervariables("logon_user")
MyVar=MyVar & ""
MyPos = InstrRev(MyVar, "/", -1, 1)
UserName=Mid(MyVar,MyPos+1,Len(MyVar))
IF trim(UserName) & "" = "" THEN
Response.write("Error in Validate User routine")
ELSE
UserName=Right(UserName,(len(UserName)-instr(Username,"\")))
userSQL = ("SELECT * FROM tblUsers WHERE UserName = '" & UserName & "'")
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
set rstemp=conntemp.execute(userSQL)
IF rstemp.eof THEN
response.write ("ERROR 127:NO USERLIST in " & userSQL)
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
ELSE
userArray=rstemp.getrows
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
END IF
myUserName=UserName
myUserID=userArray(0,0)
END IF
%>
to collect the AD login name and compare it to a SQL Server DB. You should be able adapt it to fit your environment. The only requirement is that the directory this ASP page is in needs to have the anonymous login disabled and Integrated Authentication enabled. There are also several threads in this forum related to this topic. Try a search. Does that help any? EDIT: I also have a script tucked away somewhere that automatically adds the user to the DB if not found....I'll see if I can dig it up.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
willard31
Posts: 8 Joined: 11/10/2004 Status: offline
|
RE: Connect to AD Global Catalog - 11/10/2004 15:40:19
The users are calling in to helpdesk, so the AD login name that it detects would just be the support person who is entering the call. I already have anonymous disabled and integrated enabled on all folders in the site. I actually have been able to pull some names from AD, but the only way it works is by "hard-coding" username and password in the code. (see below) This seems like a security issue that I would rather avoid. <%@ Language=VBScript %> <% Option Explicit Dim con,rs,Com,objADsPath,objDomain %> <html> <head> <meta http-equiv="Content-Language" content="en-us"> </head> <body bgcolor="#CCCCCC"> <p> <font face="Tahoma" size="2"><b>Name, Department, Phone, Email Address</b></font></p> <p> <font size="2" face="Tahoma"> <% Set objDomain = GetObject ("GC://RootDSE") objADsPath = objDomain.Get("defaultNamingContext") Set objDomain = Nothing Set con = Server.CreateObject("ADODB.Connection") con.provider ="ADsDSOObject" con.Properties("User ID") = "na\mw23377" con.Properties("Password") = "password" con.Properties("Encrypt Password") = False con.open "Active Directory Provider" Set Com = CreateObject("ADODB.Command") Set Com.ActiveConnection = con Com.CommandText ="select department,name,telephonenumber,mail from 'GC://"+objADsPath+"' WHERE name ='Mike*'" Set rs = Com.Execute Do While Not rs.EOF Or rs.BOF Response.Write rs("name") & ", " Response.Write rs("department") & ", " Response.Write rs("telephonenumber") & ", " Response.Write rs("mail") & "<BR>" rs.MoveNext Loop rs.Close con.Close Set rs = Nothing Set con = Nothing %> </font></p> <p> </p> </body> </html>
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|