Hi,
I am trying to query AD for sAMAccountName attribute for given email.
My code is as follows: -
-
Dim ldapSearchBaseDn,ldapSearchHost,ldapUser,ldapPwd
-
-
ldapSearchBaseDn = "dc=test,dc=com" ''"base dn"
-
ldapSearchHost = "IP of domain system"
-
ldapUser = "domain\username"
-
ldapPwd = "password"
-
email = "test@testmail.com"
-
Set oConn = Server.CreateObject("ADODB.Connection")
-
-
oConn.Provider = "ADSDSOObject"
-
oConn.properties("User ID") = ldapUser
-
oConn.properties("Password") = ldapPwd
-
oConn.Properties("Encrypt Password") = true
-
oConn.Open "Ads Provider"
-
-
Set rs = oConn.Execute("<LDAP://" & ldapSearchHost & "/" & ldapSearchBaseDn &">;" &_
-
"(&(objectClass=user)(mail=" & email & "));" &_
-
"sAMAccountName;subtree")
-
-
When I am running the above code as vbs file, my code is running without any issue and returning sAMAccountName for given email.
But when I am running same query from ASP page, then I am getting following Error:
Error# -2147217865
Error Desc= An operations error occurred
Error Source - Active Directory
Please help me in solving the above issue. Its very urgent.
Thanks,
Anu
6 11572
The problem is probably that the iusr account doesn't have access to AD. When you run it from a .vbs file you are probably executing it yourself, so it runs under your username. Go into IIS and (if you dare) set the asp process to run under your user account instead of iusr. I bet that will fix the problem.
Jared
Thanks for reply.
I am member of "domain Admin" group in AD.
I have to run this query without changing IIS settings.
I have tried the same in 2 different systems
1.Error "Table does not existss" if I run same query from asp page published in windows2003
2. "Operation error occured" if I run from windows2008 system
Does it make any difference? As I am getting different error when running in windows2003 system.
I had run same query successfully a long time back from windows2003 system.
Thanks,
Anu
The bottom line is there is nothing wrong with the script, the problem is the account the script uses when it executes. It does not run under your user credentials, it runs as a service account called "iusr_(computername)". That account doesn't usually have very many permissions, and it isn't a member of the AD.
I don't know of any way to do this without changing IIS settings. I guess you could try to add the iusr account to the domain, but I've never tried that, not sure if it can work. You could also try increasing iusr's permissions.
Jared
Hi jhardman,
My website is published in IIS7.0 in windows2008 system.
The main IIS settings are:
Authentication - Anonymous
Authorization rules - allow all
.Net trust levels - full
The Application Pool settings are as below:
Managed Pipeline Mode - Integrated
Identity - LocalSystem
Load User Profile - false
Please advise ,What do I need to change in above settings to run my script?
Thanks,
Anu
go into IIS (type inetmgr into the run prompt)
select your server
double click on authentication
right click on "anonymous authentication"
select "edit" and you will see the above image
click on "set..." to change user
Let me know if this works.
Jared
Hi Jared,
I need not to make any changes in IIS and I get solution with following script: -
ldapSearchBaseDn = "dc=abc,dc=com"
-
ldapSearchHost = "AD IP"
-
ldapUser = "AD User"
-
ldapPwd = "password"
-
email = "abc@xyz.com"
-
-
strQuery = "<LDAP://"& ldapSearchHost & "/" & ldapSearchBaseDn &">;" &_
-
"(&(objectCategory=user)(mail=" & email & "));" &_
-
"samAccountName;" &_
-
"subtree"
-
-
Const ADS_CHASE_REFERRALS_SUBORDINATE = &H20
-
-
'Start the ADO connection
-
Set oConnection1 = CreateObject("ADODB.Connection")
-
Set objCommand = CreateObject("ADODB.Command")
-
oConnection1.Provider = "ADsDSOObject"
-
oConnection1.Properties("User ID") = user
-
oConnection1.Properties("Password") = pwd
-
oConnection1.Properties("Encrypt Password") = True
-
oConnection1.Open "ADsDSOObject"
-
objCommand.ActiveConnection = oConnection1objCommand.CommandText = strQuery
-
objCommand.Properties("Cache Results") = False
-
objCommand.Properties("Chase Referrals") = ADS_CHASE_REFERRALS_SUBORDINATE
-
-
Set rs = objCommand.Execute
-
Set objCommand = nothing
-
-
If Err.Number = 0 then
-
if not rs.eof then
-
user = trim(rs("sAMAccountName").value)
-
end if
-
end if
-
But now I have one more issue. I have created one file test.txt in c:\windows\temp folder. I am trying to read that file. But when i check for its existence, its returning me false i.e. file does not exists.
My code is as follows: -
Dim fileName,fso
-
ForReading = 1
-
fileName="C:\WINDOWS\Temp\MacList.txt"
-
-
set fso=Server.createobject("scripting.FileSystemObject")
-
-
If fso.FileExists(fileName) then
-
//code to handle it
-
else
-
//file not exists
-
end if
-
-
and above code is returning that file does not exists.
Please help.
Thanks
Anu
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Stan |
last post by:
Ocasionally I get this error message:
"A severe error occurred on the current command. The results, if any,
should be discarded"
There is an arcticle in MSDN describing this problem, but it...
|
by: timVerizon |
last post by:
Hoping someone can help here..
Our application (C#.Net) was receiving IBM.Data.DB2.DB2Exceptions
ERROR SQL0904N Unsuccessful execution
caused by an unavailable resource. Reason code: '', type...
|
by: Angel |
last post by:
I'm trying to connect to a fixed IP address (eg. http://10.60.903.50/TempFile) in order to retrieve one accii line of text in TempFile.
I try to read the information with this code:
string...
|
by: David Mediavilla |
last post by:
I am writing a client for an HTTPS web service using WSE 1.0 but I
always get an error like "The underlying connection was closed: An
unexpected error occurred on a send."
Sometimes the error...
|
by: mike_li |
last post by:
On Window 2000 Professional Server
DB2 UDB
Level:
DB2 code release "SQL07029" with level identifie
"030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and
"WR21337".
In the...
|
by: pinky |
last post by:
Hi all
I am having one web service where in at a time of calling one webmethod
through client application i am continuously getting following error :-
The underlying connection was...
|
by: MLH |
last post by:
Private Sub ButtonP_Click()
On Error GoTo Err_ButtonP_Click
Dim ThisForm As String
ThisForm = Me.Name
Exit_ButtonP_Click:
Exit Sub
Err_ButtonP_Click:
Dim r As String, k As String, Message3...
|
by: jj555s |
last post by:
I get a Message that says "No error occured." when I tried to write in a file. What does it mean?
|
by: =?Utf-8?B?Sm9hY2hpbQ==?= |
last post by:
I have a bitmap which I have retreived through the WebBrowser DrawToBitmap
method into a Bitmap. When I try to save the bitmap I get
"ExternalException occurred
A generic error occurred in...
|
by: AnuSumesh |
last post by:
Hi All,
I want to get MAC address of client machine. I am using folllowing code in asp using vbscript:
Set objWshShell = Server.CreateObject("WScript.Shell")
strToExec = "nbtstat -a " &...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |