Folks
I have found a code that I am trying to use to query active directory. The code executes without a problem so I am assuming the syntax works. My problems is that a variable I am using does not retain its value. In the AD query it shows up blank, which really puzzles me. See the code I have created below from an article I found that was posted. -
-
<%@ LANGUAGE=VBSCRIPT %>
-
<%Option Explicit%>
-
-
<%
-
Function getADUserInfo(strUID)
-
Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strName, strCN, strLastLogin, strSid, strBase
-
'on error resume next
-
strGeneralLookupError = false
-
strUID = "UserName"
-
This is the statement that returns an empty value. -
strBase = "<LDAP://DC=subdomain,DC=subdomain,DC=primarydomain,DC=masterdomain>
-
response.write strbase
-
strFilter = "(&(objectCategory=person)(objectClass=user)(SAMAccountName=*" & strUID & "))"
-
strAttributes = "cn, mail, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber"
-
'strAttributes = "cn, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber"
-
strScope = "subtree"
-
strFullCommand = strBase & ";" & strFilter & ";" & strAttributes & ";" & strScope
-
-
-
response.write strfullcommand
-
-
set rsADUserInfo = Server.CreateObject("ADODB.Recordset")
-
set rsADUserInfo = connAD.Execute(strFullCommand)
-
if err.number <> 0 then
-
strGeneralLookupError = true
-
end if
-
set getADUserInfo = rsADUserInfo
-
set rsADUserInfo = Nothing
-
End Function
-
-
Sub getUserData(p_strUserID)
-
'on error resume next
-
set rsUserData = Server.CreateObject("ADODB.Recordset")
-
set rsUserData = getADUserInfo(p_strUserID)
-
if not rsUserData.EOF then
-
strUserGN = rsUserData("givenName")
-
strUserSN = rsUserData("sn")
-
strUserOU = rsUserData("company")
-
strUserEmail = rsUserData("mail")
-
strUserPhone = rsUserData("telephoneNumber")
-
else
-
strADLookupSuccess = false
-
end if
-
rsUserData.Close
-
set rsUserData = Nothing
-
End Sub
-
-
'on error resume next
-
-
response.expires = 0
-
-
DIM connAD, rsUserData, rsADUserInfo
-
DIM strUserGN, strUserSN, strUserOU, strUserEmail, strUserPhone
-
DIM strBase, strFilter,strAttributes, strScope, strFullCommand
-
DIM strGeneralLookupError, strADLookupSuccess
-
DIM strUserID
-
-
strUserGN = "The user can not be found in the system."
-
strGeneralLookupError = false
-
strADLookupSuccess = true
-
-
set connAD = Server.CreateObject("ADODB.Connection")
-
connAD.Provider = "ADsDSOObject"
-
connAD.Open "Active Directory Provider"
-
-
strUserID = "JuanPGomez"
-
call getUserData(strUserID)
-
-
connAD.Close
-
set connAD = Nothing
-
%>
-
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
-
<title>ASP Code to access AD with LDAP Page</title>
-
</head>
-
<body>
-
<%=strUserGN%>
-
<%=strUserSN%><br />
-
<%=strUserOU%><br />
-
<%=strUserEmail%><br />
-
<%=strUserPhone%><br />
-
</body>
-
</html>
-
0 1720 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ran Davidovitz |
last post by:
Hi.
We need to create a view of our active directory users (we have 2500).
I found out that there is max page size of 1000, so we cannot get more
data.
Anyone found a solution to that...
|
by: JasonM |
last post by:
Help!
I'm new to C# and am having trouble with the following code:
.....
DirectoryEntry root = new DirectoryEntry("LDAP://<DOMAIN>");
DirectorySearcher searcher = new DirectorySearcher(root);...
|
by: mpriem |
last post by:
Hi,
I am trying to enumerate Exchange Admin groups, but fail to with the
folowing code. Can someone help me with this issue.
The executing user has sufficient permissions.
using System;
...
|
by: Arvind P Rangan |
last post by:
Hi,
How do u interpret a Active Directory Structure into code format.
Like i have a ADS Structrue
like this
main.domain.com
+ AB
+ UB
+ AC
All my information are in AC
|
by: Andrew |
last post by:
Hey all,
Working on revamping our Intranet here and making use of the LDPA, Active
Directory, Directory Services, etc. that .Net provides. I am still fairly
new on this subject, so the problem...
|
by: Tash |
last post by:
I am having a weird problem. I am trying to use the following code to query
active directory.
Function IsExistInAD(ByVal loginName As String) As Boolean
Dim userName As String =...
|
by: Chung Leong |
last post by:
In this brief tutorial I'll describe how you retrieve information from
an Active Directory through the OLE-DB extension. While it is possible
to use the LDAP extension to achieve the same goal, as...
|
by: dug04 |
last post by:
Hi
I am trying to write a query that will select all users in the Organization bucket in active directory. The problem is that within the Organization bucket, there are many other buckets. I...
|
by: kooch54 |
last post by:
I am trying to write a script to simply query the group members in an
active directory group. I need to use LDAP to make sure I capture any
global global group nestings that may occur. I already...
|
by: =?Utf-8?B?YXppZWdsZXI=?= |
last post by:
Hello, everybody.
I'd like to do this: For a big program (a web service) I need information
about the usergroups an active-directory-user is member of. To be more
precise, I need to know if a...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |