I'm trying to retrieve the users email address via ADSI in ASP.
So far, I have the following code:
Set oUser = GetObject("WinN T://domain/" & Request.Form("U ID") & ",user")
Response.Write oUser.EmailAddr ess
But I get the following message:
"The directory property cannot be found in the cache. "
Any ideas where I am going wrong?
Thanks 8 9072
On Fri, 19 Nov 2004 16:33:30 -0000, "CJM"
<cj*******@news groups.nospam> wrote: I'm trying to retrieve the users email address via ADSI in ASP.
So far, I have the following code:
Set oUser = GetObject("WinN T://domain/" & Request.Form("U ID") & ",user") Response.Wri te oUser.EmailAddr ess
But I get the following message:
"The directory property cannot be found in the cache. "
Any ideas where I am going wrong?
First guess is you're looking for a directory property that isn't in
the cache... :)
You're going to need to get specific and tell us versions of OS,
Active Directory or not, etc. Also, if the email address isn't in
your directory, you're still not going to get anything.
Jeff
CJM wrote: I'm trying to retrieve the users email address via ADSI in ASP.
So far, I have the following code:
Set oUser = GetObject("WinN T://domain/" & Request.Form("U ID") & ",user") Response.Write oUser.EmailAddr ess
But I get the following message:
"The directory property cannot be found in the cache. "
Any ideas where I am going wrong?
Hi,
I find that EmailAddress is not supported by the WinNT provider. You need to
uses the LDAP provider.
EmailAddress is actually a property method that returns the value of the
mail attribute (which also is not supported by WinNT).
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
"Jeff Cochran" <je*********@zi na.com> wrote in message
news:41******** *********@msnew s.microsoft.com ... On Fri, 19 Nov 2004 16:33:30 -0000, "CJM" <cj*******@news groups.nospam> wrote:
I'm trying to retrieve the users email address via ADSI in ASP.
So far, I have the following code:
Set oUser = GetObject("WinN T://domain/" & Request.Form("U ID") & ",user") Response.Writ e oUser.EmailAddr ess
But I get the following message:
"The directory property cannot be found in the cache. "
Any ideas where I am going wrong?
First guess is you're looking for a directory property that isn't in the cache... :)
You're going to need to get specific and tell us versions of OS, Active Directory or not, etc. Also, if the email address isn't in your directory, you're still not going to get anything.
Jeff
Jeff,
My development server is XPSP2 and we are using Active Directory 2003
(Native mode).
All the email address are populated.
Thanks
Chris
"Richard Mueller [MVP]" <rl************ **@ameritech.NO SPAM.net> wrote in
message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Hi,
I find that EmailAddress is not supported by the WinNT provider. You need to uses the LDAP provider.
EmailAddress is actually a property method that returns the value of the mail attribute (which also is not supported by WinNT).
-- Richard
Thanks Richard, but can you point me in the right direction for the LDAP
code. I gather its more involved than just swapping 'WinNT' for 'LDAP' - a
different string entirely?
Cheers
Chris
On Tue, 23 Nov 2004 12:39:53 -0000, "CJM"
<cj*******@news groups.nospam> wrote: "Jeff Cochran" <je*********@zi na.com> wrote in message news:41******* **********@msne ws.microsoft.co m... On Fri, 19 Nov 2004 16:33:30 -0000, "CJM" <cj*******@news groups.nospam> wrote:
I'm trying to retrieve the users email address via ADSI in ASP.
So far, I have the following code:
Set oUser = GetObject("WinN T://domain/" & Request.Form("U ID") & ",user") Response.Wri te oUser.EmailAddr ess
But I get the following message:
"The directory property cannot be found in the cache. "
Any ideas where I am going wrong?
First guess is you're looking for a directory property that isn't in the cache... :)
You're going to need to get specific and tell us versions of OS, Active Directory or not, etc. Also, if the email address isn't in your directory, you're still not going to get anything.
Jeff
Jeff,
My development server is XPSP2 and we are using Active Directory 2003 (Native mode).
All the email address are populated.
In AD? If so, you'll want to use LDAP to retrieve them instead of
WMI.
Jeff
On Tue, 23 Nov 2004 12:42:03 -0000, "CJM"
<cj*******@news groups.nospam> wrote: "Richard Mueller [MVP]" <rl************ **@ameritech.NO SPAM.net> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Hi,
I find that EmailAddress is not supported by the WinNT provider. You need to uses the LDAP provider.
EmailAddress is actually a property method that returns the value of the mail attribute (which also is not supported by WinNT).
-- Richard
Thanks Richard, but can you point me in the right direction for the LDAP code. I gather its more involved than just swapping 'WinNT' for 'LDAP' - a different string entirely?
Lots of sampels availble, try: http://www.4guysfromrolla.com/webtech/041800-1.shtml
Jeff
Here's the solution I ended up with:
<%@language="vb script" %>
<%
Option Explicit
Dim objRootDSE, strDNSDomain, objConnection, strQuery
Dim objRecordSet, strName, strDN
Dim strBase, strFilter, strAttributes
' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP ://RootDSE")
strDNSDomain = objRootDSE.Get( "defaultNamingC ontext")
' Use ADO to search Active Directory.
Set objConnection = CreateObject("A DODB.Connection ")
objConnection.P rovider = "ADsDSOObje ct"
objConnection.P roperties("User ID") = "domain\usernam e"
objConnection.P roperties("Pass word") = "password"
objConnection.O pen "Active Directory Provider"
' Search for all user objects. Sort recordset by DisplayName.
strBase = "<LDAP://" & strDNSDomain & ">"
strFilter = "(&(objectCateg ory=person)(obj ectClass=user)( sAMAccountName= " &
Session("UID") & "))"
strAttributes = "mail"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
Set objRecordSet = objConnection.E xecute(strQuery )
If objRecordSet.EO F Then
response.Write "bolox"
End If
' Loop through results
Do Until objRecordSet.EO F
response.Write "Email Address: " & objRecordSet.Fi elds("mail")
objRecordSet.Mo veNext
Loop
' Clean up.
objConnection.C lose
Set objRootDSE = Nothing
Set objConnection = Nothing
Set objRecordSet = Nothing
%>
I was told that the mail property is not always reliable, ie may not be
populated, and that the proxyaddresses field would be better, but that
returns a multi-value responsew which I can't seem to handle. Besides, mail
seems to work OK for me...
Thanks
Chris
Hi,
Some comments.
1. If you know "mail" is populated, use it.
2. You don't need to specify a userID and password unless you are running
the code with an account that does not have permisssion to read the
attributes.
3. To read a multi-valued attribute, you can loop through the collection
with a "For Each" loop. However, you must account for the possibility that
the attribute will have no values. For example:
' Retrieve a multi-valued attribute .
strAttributes = "proxyAddresses "
Do Until adoRecordset.EO F
colMail = adoRecordset.Fi elds("proxyAddr esses")
If IsEmpty(colMail ) Then
' The attribute is empty (has no values).
Response.Write "No Email address"
Else
' The attribute has one or more values - enumerate.
For Each strMail In colMail
Response.Write "Email Address: " & strMail
Next
End If
Loop
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
"CJM" <cj*******@news groups.nospam> wrote in message
news:eN******** ******@TK2MSFTN GP15.phx.gbl... Here's the solution I ended up with:
<%@language="vb script" %> <% Option Explicit
Dim objRootDSE, strDNSDomain, objConnection, strQuery Dim objRecordSet, strName, strDN Dim strBase, strFilter, strAttributes
' Determine DNS domain name from RootDSE object. Set objRootDSE = GetObject("LDAP ://RootDSE") strDNSDomain = objRootDSE.Get( "defaultNamingC ontext")
' Use ADO to search Active Directory. Set objConnection = CreateObject("A DODB.Connection ") objConnection.P rovider = "ADsDSOObje ct" objConnection.P roperties("User ID") = "domain\usernam e" objConnection.P roperties("Pass word") = "password" objConnection.O pen "Active Directory Provider"
' Search for all user objects. Sort recordset by DisplayName. strBase = "<LDAP://" & strDNSDomain & ">" strFilter = "(&(objectCateg ory=person)(obj ectClass=user)( sAMAccountName= "
& Session("UID") & "))" strAttributes = "mail" strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
Set objRecordSet = objConnection.E xecute(strQuery )
If objRecordSet.EO F Then response.Write "bolox" End If
' Loop through results Do Until objRecordSet.EO F response.Write "Email Address: " & objRecordSet.Fi elds("mail") objRecordSet.Mo veNext Loop
' Clean up. objConnection.C lose Set objRootDSE = Nothing Set objConnection = Nothing Set objRecordSet = Nothing
%>
I was told that the mail property is not always reliable, ie may not be populated, and that the proxyaddresses field would be better, but that returns a multi-value responsew which I can't seem to handle. Besides,
mail seems to work OK for me...
Thanks
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: zsh-users-help |
last post by:
Hi! This is the ezmlm program. I'm managing the
zsh-users@sunsite.dk mailing list.
To confirm that you would like
python-list@python.org
removed from the zsh-users mailing list, please send an empty reply
to this address:
|
by: tcm-users-request |
last post by:
This pre-recorded message is being sent in response to your recent
email to tcm-users-request@listserv.cs.utwente.nl.
All routine administrative requests (including subscriptions and
unsubscriptions) concerning this mailing list are handled by an
automated server. Please read this message carefully to find the
information relevant to you.
SUBSCRIBING
===========
|
by: Viviana Vc |
last post by:
How can I programatically do the equivalent of the following:
cacls "C:\Program Files\test" /T /G Everyone:f ?
Thanks,
Viv
|
by: codewarr2000 |
last post by:
Having problem with retrieving a class instance item from a Vector.
This is the result of the code below.
Also a weird note: If I dont declare as:
TYPE_VECTOR_BANKED_MEMORY_DATA
bankedDataMemoryLayout(NUMBER_BANKS);
but an empty vector
TYPE_VECTOR_BANKED_MEMORY_DATA bankedDataMemoryLayout;
The program crashes on the 3rd insertion???
|
by: Alistair |
last post by:
Hi all,
I am creating a database based site that keeps track of books, who has read
them and the comments they have.
After a little help in M.P.I.asp.DB I managed to create a database (access
2000) as follows
USERS TABLE
| |
by: Larry |
last post by:
OK, I've been searching around the net for numerous hours and seem to just be
getting more confused about handling special characters.
In my host's configuration MagicQuotes is ON. (I understand this is considered
a bad thing by many)
A user submitted an email in the form 'Bob Smith' <bob@nospam.com>
Now when I look in the MySql database (via PhpMyAdmin) it's exactly that, but
when I try to retrieve it with a standard query, it echo's...
|
by: 4Ankit |
last post by:
hello all, i am having some difficulty retrieving information from my
form. I want to add content in my table but the content i want to add
to the table is what the user inputs in my form.
Basically i want to know how i retrieve information from the form so i
can disaply it in the table.
i have put the code i am using below, the feature i cannot get to work
is the change content function. I want the email address entered by
the...
|
by: smartin |
last post by:
Hi,
I'm having problem retrieving data from an SQL stored procedure. I tried debugging but it wont give a the reason for the error. it just throws an exception after executing cmd.ExecuteNonQuery without any details. Can anyone please help me.. Im stuck on it since 2 days
Thanks
Stored Procedure
|
by: vpriya6 |
last post by:
Hi guys,
I am new to Ajax, xml and javascript.
I want to know how can I retrieve data from xml and display in the html page?
please help me out.
suppose my xml file is customer.xml the code is below:
<CUSTOMER>
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |