Hi, Carlos
I finally got it. Thanks so much for your help.
Shan
---------------------------------
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
[Non-text portions of this message have been removed]
Shan -
Here is some C# code that does what you were looking for:
private void DisplayUserDetails(string w2kLogin)
{
string adPath = "LDAP://dc=yourdomain,dc=com";
string qry = String.Format("(&
(objectCategory=person)(sAMAccountName={0}))", w2kLogin);
string[] attribs = new string[]
{"displayName", "mail"};
DirectoryEntry de = new DirectoryEntry
(adPath, null, null, AuthenticationTypes.Secure);
DirectorySearcher ds = new DirectorySearcher
(de,qry,attribs);
try
{
SearchResult sr = ds.FindOne();
if(sr != null)
{
foreach(string s in attribs)
{
if
(sr.Properties.Contains(s))
HttpContext.Current.Response.Write(s + ": " + sr.Properties[s]
[0].ToString());
}
}
else
HttpContext.Current.Response.Write("User Not Found....");
}
catch(Exception ex)
{
string message;
if(ex.InnerException != null)
message =
ex.InnerException.Message;
else
message = ex.Message;
HttpContext.Current.Response.Write
(message);
}
finally
{
de.Close();
de.Dispose();
ds.Dispose();
}
}
Just update your LDAP path and supply the Windows login (without
domain prefixed) to this method. If you are not using impersonation,
then replace the nulls in the DirectoryEntry constructor with a valid
domain\username and password for the domain.
Was this on the Domain Controller, and what Windows Version plus what SP are
you running?
-----Original Message-----
From: ngogic <ngogic@...> [mailto:ngogic@...]
Sent: 11 February 2003 04:42 PM
To: ADSIANDDirectoryServices@yahoogroups.com
Subject: [ADSIANDDirectoryServices] AD problem
I tried to open AD snap-in from the MMC and got the following
message: "Naming information cannot be located because: library not
registered" Does someone know how to solve that problem?
To unsubscribe from this group, send an email to:
ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
I tried to open AD snap-in from the MMC and got the following
message: "Naming information cannot be located because: library not
registered" Does someone know how to solve that problem?
Quick code fix:
Myresults = searcher.FindAll() should be
Myresults = Mysearcher.FindAll()
-----Original Message-----
From: Carlos Magalhaes
Sent: 11 February 2003 10:41 AM
To: 'ADSIANDDirectoryServices@yahoogroups.com'
Subject: RE: [ADSIANDDirectoryServices] Re: Access Active Directory for Us
er F ull Name and Email Address
Hello Shan,
Ok it's difficult to see what is happening with out the full code you are
testing (and I know I posted the code but I don't know what parameters you
inserted within the areas specified.) But here is something I dug out for
you.
Ok try this:
To connect to Active Directory, you can either specify a path using Global
Catalog (GC://) syntax, or you can use a standard LDAP path (LDAP://). The
syntax and path to use depends on your network environment. For example,
working with my internal network, I decided to use the Global Catalog syntax
because it allows me to search across my entire enterprise network (the
entire Active Directory forest). Instead of a path that includes a server
name, I specify just "GC://dc=Developers,dc=test,dc=com" (assuming my domain
is called Developers.test.com), which tells ADSI to connect to a global
catalog server for the specified domain. If you wish, you can also connect
without specifying any path at all. If you use a DirectorySearcher object
without any root object supplied, it will automatically use the current
domain for its search. For more information on determining the correct path
for your network, check out these references:
Dim rootEntry As New
DirectoryEntry("GC://dc=[YourDomain],dc=[YourDomain],dc=[YourRootDomain]")
Dim Mysearcher As New DirectorySearcher(rootEntry)
Mysearcher.PropertiesToLoad.Add("cn")
Mysearcher.PropertiesToLoad.Add("mail")
'searcher.PropertiesToLoad.AddRange(New String() {"cn", "mail"})
'would also work and saves you some code
Mysearcher.Filter = "(&(anr=YourUserToCheck)(objectCategory=person))"
Dim Myresults As SearchResultCollection
Myresults = searcher.FindAll()
Dim result As SearchResult
For Each result In Myresults
Response.Write("name=" + result.Properties("cn")(0)+
"E-mail=" + result.Properties("mail")(0) +"<br>")
Next
HTH
Carlos
For more info check
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/dotnetadsearch.asp
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/h
tml/dotnetadsearch.asp>
-----Original Message-----
From: shan_wang2000 <shan_wang2000@...>
[mailto:shan_wang2000@...]
Sent: 10 February 2003 11:07 PM
To: ADSIANDDirectoryServices@yahoogroups.com
Subject: [ADSIANDDirectoryServices] Re: Access Active Directory for User F
ull Name and Email Address
Hi, Carlos,
Thanks for your code. I tried to use it to get the information I
need but failed.
The filter I used is: mySearcher.Filter = "(CN=Users)"
I also tried : mySearcher.Filter="(CN=Domain Users)"
The result is a bunch of information such as: objectClass=top,
objectGUID=system.Byte[], objectid=.... uSNcreated=system._ComObject
But I want to get all User Email Address and Full name. Could you
tell me how to reach these properties?
By the way, the interface for my Active Directory is the following:
When I opened 'Active Directory Users and Computers', there are
several subfolders: Computers, Domain Controllers, Users... When I
selected 'Users', there are subfolders such as: Administrators,
Domain Users,.... I double click on 'Domain Users', the 'Domain
Users Properties' dialog box shows, when I selected 'Members' tab, I
got a list of user names. I doubleclick on one user
names, '...Properties' dialog box shows, I can find user email
address under 'General' tab.
Thanks so much for your help
Shan
--- In ADSIANDDirectoryServices@yahoogroups.com, Carlos Magalhaes
<CarlosM@t...> wrote:
> Hey Shan,
>
> I noticed that you did request a VB.NET example in the previous
post on a
> diffrent group before you posted here so here is a vb.net example
that will
> display, Property Names and all the properties values.
>
> You just have to read through the code and set the relevant parts
according
> to your domain.
>
> System.DirectoryServices.DirectoryEntry
> ("LDAP://servername/o=org/ou=members/ou=somememeber")
>
> Dim mySearcher As New DirectorySearcher(oDirectory)
> Dim oDirEntry As DirectoryEntry
> Dim oPropNames As ICollection
> Dim oProperties As DirectoryServices.PropertyCollection
> Dim oPropValues As PropertyValueCollection
> Dim oValue As Object
> Dim oResult As SearchResult
> Dim sPropName As String
> mySearcher.SearchScope = SearchScope.Subtree
> mySearcher.ReferralChasing = ReferralChasingOption.All
> mySearcher.Filter = "([use an ldap filter here])"
> Try
> For Each oResult In mySearcher.FindAll
> oDirEntry = oResult.GetDirectoryEntry
> Debug.WriteLine(oDirEntry.Path)
> oProperties = oDirEntry.Properties
> For Each sPropName In
> oProperties.PropertyNames
> Debug.WriteLine(sPropName & "=")
> oPropValues = oProperties(sPropName)
> For Each oValue In oPropValues
> Debug.WriteLine(" " &
> oValue.ToString)
> Next
> Next
> Next
> Debug.WriteLine("done")
> Catch ex As Exception
> Debug.WriteLine(ex.Message)
> End Try
>
> If this is not what you looking for please let us know and you
will have to
> modify this a little bit to work on a asp.net web page but if you
need help
> doing that just let us know.
>
> If you are actually needing this in C# please also let us know.
>
> HTH
>
> Carlos
>
> -----Original Message-----
> From: Shan Wang
> To: ADSIANDDirectoryServices@yahoogroups.com
> Sent: 2/10/03 5:45 PM
> Subject: [ADSIANDDirectoryServices] Access Active Directory for
User Full
> Name and Email Address
>
>
> Hi, all,
>
> I am new to Active Directory programming. I want to access Active
> Directory for user full name and email address, but I couldn't get
them.
> My code to access Active Directory is the following:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> string strLDAP=LDAP://CN=Domain
> Users,CN=Users,DC=Mydomain,DC=com;
> DirectoryEntry m_obDirEntry=new DirectoryEntry(strLDAP);
> DirectorySearcher srch=new DirectorySearcher(m_obDirEntry);
> //srch.Filter = "(objectClass=Members)";
> SearchResultCollection results;
> results=srch.FindAll();
> foreach (SearchResult result in results)
> {
> ResultPropertyCollection propColl=result.Properties;
> foreach (string strKey in propColl.PropertyNames)
> {
> foreach (object obProp in propColl[strKey])
> {
> Response.Write("name=" + obProp.GetType().ToString() +
> "Value=" + obProp.ToString()+"<br>");
> }
> }
> }
>
> From this code, I couldn't get the information I need. When I
opened
> 'Active Directory Users and Computers' from Win2K Advance Server,
there
> are several subfolders: Computers, Domain Controllers, Users...
When I
> selected 'Users', there are subfolders such as: Administrators,
Domain
> Users,.... I double click on 'Domain Users', the 'Domain Users
> Properties' dialog box shows, when I selected 'Members' tab, I got
a
> list of user names. I doubleclick on my names, '...Properties'
dialog
> box shows, I can find my email address under 'General' tab.
>
> My question is, how can I get to full name and the email address
> properties and retrieve them?
>
> Thanks a lot!
>
> Shan
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now
>
> [Non-text portions of this message have been removed]
>
>
>
> To unsubscribe from this group, send an email to:
> ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
> ----------
>
> -------------------------------------------------------------
> This email and any files transmitted are
> confidential and intended solely for the
> use of the individual or entity to which
> they are addressed, whose privacy
> should be respected. Any views or
> opinions are solely those of the author
> and do not necessarily represent those
> of the Trencor Group, or any of its
> representatives, unless specifically
> stated.
>
> Email transmission cannot be guaranteed
> to be secure, error free or without virus
> contamination. The sender therefore
> accepts no liability for any errors or
> omissions in the contents of this message,
> nor for any virus infection that might result
> from opening this message. Trencor is not
> responsible in the event of any third party
> interception of this email.
>
> If you have received this email in error please notify
> postmaster@t... For more information about
> Trencor, visit www.trencor.net <http://www.trencor.net>
>
>
>
> [Non-text portions of this message have been removed]
To unsubscribe from this group, send an email to:
ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
To unsubscribe from this group, send an email to:
ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
Hello Shan,
Ok it's difficult to see what is happening with out the full code you are
testing (and I know I posted the code but I don't know what parameters you
inserted within the areas specified.) But here is something I dug out for
you.
Ok try this:
To connect to Active Directory, you can either specify a path using Global
Catalog (GC://) syntax, or you can use a standard LDAP path (LDAP://). The
syntax and path to use depends on your network environment. For example,
working with my internal network, I decided to use the Global Catalog syntax
because it allows me to search across my entire enterprise network (the
entire Active Directory forest). Instead of a path that includes a server
name, I specify just "GC://dc=Developers,dc=test,dc=com" (assuming my domain
is called Developers.test.com), which tells ADSI to connect to a global
catalog server for the specified domain. If you wish, you can also connect
without specifying any path at all. If you use a DirectorySearcher object
without any root object supplied, it will automatically use the current
domain for its search. For more information on determining the correct path
for your network, check out these references:
Dim rootEntry As New
DirectoryEntry("GC://dc=[YourDomain],dc=[YourDomain],dc=[YourRootDomain]")
Dim Mysearcher As New DirectorySearcher(rootEntry)
Mysearcher.PropertiesToLoad.Add("cn")
Mysearcher.PropertiesToLoad.Add("mail")
'searcher.PropertiesToLoad.AddRange(New String() {"cn", "mail"})
'would also work and saves you some code
Mysearcher.Filter = "(&(anr=YourUserToCheck)(objectCategory=person))"
Dim Myresults As SearchResultCollection
Myresults = searcher.FindAll()
Dim result As SearchResult
For Each result In Myresults
Response.Write("name=" + result.Properties("cn")(0)+
"E-mail=" + result.Properties("mail")(0) +"<br>")
Next
HTH
Carlos
For more info check
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/dotnetadsearch.asp
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/h
tml/dotnetadsearch.asp>
-----Original Message-----
From: shan_wang2000 <shan_wang2000@...>
[mailto:shan_wang2000@...]
Sent: 10 February 2003 11:07 PM
To: ADSIANDDirectoryServices@yahoogroups.com
Subject: [ADSIANDDirectoryServices] Re: Access Active Directory for User F
ull Name and Email Address
Hi, Carlos,
Thanks for your code. I tried to use it to get the information I
need but failed.
The filter I used is: mySearcher.Filter = "(CN=Users)"
I also tried : mySearcher.Filter="(CN=Domain Users)"
The result is a bunch of information such as: objectClass=top,
objectGUID=system.Byte[], objectid=.... uSNcreated=system._ComObject
But I want to get all User Email Address and Full name. Could you
tell me how to reach these properties?
By the way, the interface for my Active Directory is the following:
When I opened 'Active Directory Users and Computers', there are
several subfolders: Computers, Domain Controllers, Users... When I
selected 'Users', there are subfolders such as: Administrators,
Domain Users,.... I double click on 'Domain Users', the 'Domain
Users Properties' dialog box shows, when I selected 'Members' tab, I
got a list of user names. I doubleclick on one user
names, '...Properties' dialog box shows, I can find user email
address under 'General' tab.
Thanks so much for your help
Shan
--- In ADSIANDDirectoryServices@yahoogroups.com, Carlos Magalhaes
<CarlosM@t...> wrote:
> Hey Shan,
>
> I noticed that you did request a VB.NET example in the previous
post on a
> diffrent group before you posted here so here is a vb.net example
that will
> display, Property Names and all the properties values.
>
> You just have to read through the code and set the relevant parts
according
> to your domain.
>
> System.DirectoryServices.DirectoryEntry
> ("LDAP://servername/o=org/ou=members/ou=somememeber")
>
> Dim mySearcher As New DirectorySearcher(oDirectory)
> Dim oDirEntry As DirectoryEntry
> Dim oPropNames As ICollection
> Dim oProperties As DirectoryServices.PropertyCollection
> Dim oPropValues As PropertyValueCollection
> Dim oValue As Object
> Dim oResult As SearchResult
> Dim sPropName As String
> mySearcher.SearchScope = SearchScope.Subtree
> mySearcher.ReferralChasing = ReferralChasingOption.All
> mySearcher.Filter = "([use an ldap filter here])"
> Try
> For Each oResult In mySearcher.FindAll
> oDirEntry = oResult.GetDirectoryEntry
> Debug.WriteLine(oDirEntry.Path)
> oProperties = oDirEntry.Properties
> For Each sPropName In
> oProperties.PropertyNames
> Debug.WriteLine(sPropName & "=")
> oPropValues = oProperties(sPropName)
> For Each oValue In oPropValues
> Debug.WriteLine(" " &
> oValue.ToString)
> Next
> Next
> Next
> Debug.WriteLine("done")
> Catch ex As Exception
> Debug.WriteLine(ex.Message)
> End Try
>
> If this is not what you looking for please let us know and you
will have to
> modify this a little bit to work on a asp.net web page but if you
need help
> doing that just let us know.
>
> If you are actually needing this in C# please also let us know.
>
> HTH
>
> Carlos
>
> -----Original Message-----
> From: Shan Wang
> To: ADSIANDDirectoryServices@yahoogroups.com
> Sent: 2/10/03 5:45 PM
> Subject: [ADSIANDDirectoryServices] Access Active Directory for
User Full
> Name and Email Address
>
>
> Hi, all,
>
> I am new to Active Directory programming. I want to access Active
> Directory for user full name and email address, but I couldn't get
them.
> My code to access Active Directory is the following:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> string strLDAP=LDAP://CN=Domain
> Users,CN=Users,DC=Mydomain,DC=com;
> DirectoryEntry m_obDirEntry=new DirectoryEntry(strLDAP);
> DirectorySearcher srch=new DirectorySearcher(m_obDirEntry);
> //srch.Filter = "(objectClass=Members)";
> SearchResultCollection results;
> results=srch.FindAll();
> foreach (SearchResult result in results)
> {
> ResultPropertyCollection propColl=result.Properties;
> foreach (string strKey in propColl.PropertyNames)
> {
> foreach (object obProp in propColl[strKey])
> {
> Response.Write("name=" + obProp.GetType().ToString() +
> "Value=" + obProp.ToString()+"<br>");
> }
> }
> }
>
> From this code, I couldn't get the information I need. When I
opened
> 'Active Directory Users and Computers' from Win2K Advance Server,
there
> are several subfolders: Computers, Domain Controllers, Users...
When I
> selected 'Users', there are subfolders such as: Administrators,
Domain
> Users,.... I double click on 'Domain Users', the 'Domain Users
> Properties' dialog box shows, when I selected 'Members' tab, I got
a
> list of user names. I doubleclick on my names, '...Properties'
dialog
> box shows, I can find my email address under 'General' tab.
>
> My question is, how can I get to full name and the email address
> properties and retrieve them?
>
> Thanks a lot!
>
> Shan
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now
>
> [Non-text portions of this message have been removed]
>
>
>
> To unsubscribe from this group, send an email to:
> ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
> ----------
>
> -------------------------------------------------------------
> This email and any files transmitted are
> confidential and intended solely for the
> use of the individual or entity to which
> they are addressed, whose privacy
> should be respected. Any views or
> opinions are solely those of the author
> and do not necessarily represent those
> of the Trencor Group, or any of its
> representatives, unless specifically
> stated.
>
> Email transmission cannot be guaranteed
> to be secure, error free or without virus
> contamination. The sender therefore
> accepts no liability for any errors or
> omissions in the contents of this message,
> nor for any virus infection that might result
> from opening this message. Trencor is not
> responsible in the event of any third party
> interception of this email.
>
> If you have received this email in error please notify
> postmaster@t... For more information about
> Trencor, visit www.trencor.net <http://www.trencor.net>
>
>
>
> [Non-text portions of this message have been removed]
To unsubscribe from this group, send an email to:
ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
thanks a lot Carlos again.
Yeah I guess it would be easier just porting the queries over to ADSI
rather than getting this clunky method to work properly..
thanks for the article!
--- In ADSIANDDirectoryServices@yahoogroups.com, Carlos Magalhaes
<CarlosM@t...> wrote:
> I just need to ask you why are you trying to use this type of "SQL
query" to
> the LDAP directory?
>
> It would be much simpler to use normal ADSI and or DirectoryServices
wouldnt
> it?
>
> Here is a brilliant article to show you and explain how to bind to both
> printers on NT4 and or Ldap directories and retirve information.
>
> have a look and let us know if it helped
> http://www.winscriptingsolutions.com/Articles/Index.cfm?ArticleID=6128
>
> p.s. Dont worry about the post length ;-)
>
> HTH
> CM
>
> -----Original Message-----
> From: eyuzwa <wazoo@w...>
> To: ADSIANDDirectoryServices@yahoogroups.com
> Sent: 2/10/03 10:28 PM
> Subject: [ADSIANDDirectoryServices] Re: getting stuck querying LDAP
provider
> with SQL
>
> Hi Carlos,
> thanks for the quick reply!
>
> Okay here's how I'm doing it with some VBScript inside an ASP page.
> [begin source]
> Dim objConn, objCommand, objRS
> Set objConn = Server.CreateObject("ADODB.Connection")
> With objConn
> .Provider = "ADsDSOObject"
> .Properties("User Id") = user
> .Properties("Password")= pwd
> End With
>
> objConn.Open "ADs Provider"
>
> Set objCommand = Server.CreateObject("ADODB.Command")
> With objCommand
> .ActiveConnection = objConn
> .CommandText = "SELECT cn from
> 'LDAP://<server>/dc=<domain>,dc=com'
> WHERE objectClass='printQueue'"
> End With
>
> Set objRS = objCommand.Execute
>
> [end source]
>
> Hopefully that all came through on HTML properly..;)
>
> Now the problem is that I'm trying to request/display some attributes
> for each printer in the printerQueue (ie. printerName, location, etc).
>
> Using "normal" SQL, I would just specify the column name I need in the
> result set in the query...
>
> ie. SELECT printerName, cn from 'LDAP://<server>/dc=<domain>,dc=com'
> WHERE objectClass='printQueue'
>
> but it just blows up. :(
>
> Thanks for any advice, and I apologize for the long post here..
>
>
>
>
> --- In ADSIANDDirectoryServices@yahoogroups.com, "Carlos Magalhaes
> <CarlosM@t...>" <CarlosM@t...> wrote:
> > Hello ,
> >
> > This is interesting, can you show us a bit more code from your
> > example so that we can see how you are actually interfacing to the
> > directory.
> >
> > This will help us identify the problem, and technology you are
> using,
> > i.e. DirectoryServices ADSI , VbScript, Vb.NEt C# this all makes a
> > bit of a diffrence.
> >
> > Thanks
> >
> > Carlos
> >
> >
> > --- In ADSIANDDirectoryServices@yahoogroups.com, "eyuzwa
> > <wazoo@w...>" <wazoo@w...> wrote:
> > > Hi all,
> > >
> > > I'm trying to use a SQL query type approach for querying our LDAP
> > > server, but I'm getting stuck trying to figure out how to retrieve
> > > some attributes..
> > >
> > > ie. (for an .asp page)
> > >
> > > .CommandText = "SELECT cn from 'LDAP://<server>' WHERE
> > > objectClass='printQueue'"
> > >
> > > I've got the above query properly working, but I NEED to also grab
> > > attributes like the "printerName" or "location", etc..
> > >
> > > however if I try out..
> > >
> > > .CommandText = "SELECT printerName from 'LDAP://<server>' WHERE
> > > objectClass='printQueue'"
> > >
> > > I get some "Unspecified Error" messages on my browser..
> > >
> > > Any advice would be appreciated!
>
>
>
> To unsubscribe from this group, send an email to:
> ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
> ----------
>
> -------------------------------------------------------------
> This email and any files transmitted are
> confidential and intended solely for the
> use of the individual or entity to which
> they are addressed, whose privacy
> should be respected. Any views or
> opinions are solely those of the author
> and do not necessarily represent those
> of the Trencor Group, or any of its
> representatives, unless specifically
> stated.
>
> Email transmission cannot be guaranteed
> to be secure, error free or without virus
> contamination. The sender therefore
> accepts no liability for any errors or
> omissions in the contents of this message,
> nor for any virus infection that might result
> from opening this message. Trencor is not
> responsible in the event of any third party
> interception of this email.
>
> If you have received this email in error please notify
> postmaster@t... For more information about
> Trencor, visit www.trencor.net <http://www.trencor.net>
>
>
>
> [Non-text portions of this message have been removed]
Hi, Carlos,
Thanks for your code. I tried to use it to get the information I
need but failed.
The filter I used is: mySearcher.Filter = "(CN=Users)"
I also tried : mySearcher.Filter="(CN=Domain Users)"
The result is a bunch of information such as: objectClass=top,
objectGUID=system.Byte[], objectid=.... uSNcreated=system._ComObject
But I want to get all User Email Address and Full name. Could you
tell me how to reach these properties?
By the way, the interface for my Active Directory is the following:
When I opened 'Active Directory Users and Computers', there are
several subfolders: Computers, Domain Controllers, Users... When I
selected 'Users', there are subfolders such as: Administrators,
Domain Users,.... I double click on 'Domain Users', the 'Domain
Users Properties' dialog box shows, when I selected 'Members' tab, I
got a list of user names. I doubleclick on one user
names, '...Properties' dialog box shows, I can find user email
address under 'General' tab.
Thanks so much for your help
Shan
--- In ADSIANDDirectoryServices@yahoogroups.com, Carlos Magalhaes
<CarlosM@t...> wrote:
> Hey Shan,
>
> I noticed that you did request a VB.NET example in the previous
post on a
> diffrent group before you posted here so here is a vb.net example
that will
> display, Property Names and all the properties values.
>
> You just have to read through the code and set the relevant parts
according
> to your domain.
>
> System.DirectoryServices.DirectoryEntry
> ("LDAP://servername/o=org/ou=members/ou=somememeber")
>
> Dim mySearcher As New DirectorySearcher(oDirectory)
> Dim oDirEntry As DirectoryEntry
> Dim oPropNames As ICollection
> Dim oProperties As DirectoryServices.PropertyCollection
> Dim oPropValues As PropertyValueCollection
> Dim oValue As Object
> Dim oResult As SearchResult
> Dim sPropName As String
> mySearcher.SearchScope = SearchScope.Subtree
> mySearcher.ReferralChasing = ReferralChasingOption.All
> mySearcher.Filter = "([use an ldap filter here])"
> Try
> For Each oResult In mySearcher.FindAll
> oDirEntry = oResult.GetDirectoryEntry
> Debug.WriteLine(oDirEntry.Path)
> oProperties = oDirEntry.Properties
> For Each sPropName In
> oProperties.PropertyNames
> Debug.WriteLine(sPropName & "=")
> oPropValues = oProperties(sPropName)
> For Each oValue In oPropValues
> Debug.WriteLine(" " &
> oValue.ToString)
> Next
> Next
> Next
> Debug.WriteLine("done")
> Catch ex As Exception
> Debug.WriteLine(ex.Message)
> End Try
>
> If this is not what you looking for please let us know and you
will have to
> modify this a little bit to work on a asp.net web page but if you
need help
> doing that just let us know.
>
> If you are actually needing this in C# please also let us know.
>
> HTH
>
> Carlos
>
> -----Original Message-----
> From: Shan Wang
> To: ADSIANDDirectoryServices@yahoogroups.com
> Sent: 2/10/03 5:45 PM
> Subject: [ADSIANDDirectoryServices] Access Active Directory for
User Full
> Name and Email Address
>
>
> Hi, all,
>
> I am new to Active Directory programming. I want to access Active
> Directory for user full name and email address, but I couldn't get
them.
> My code to access Active Directory is the following:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> string strLDAP=LDAP://CN=Domain
> Users,CN=Users,DC=Mydomain,DC=com;
> DirectoryEntry m_obDirEntry=new DirectoryEntry(strLDAP);
> DirectorySearcher srch=new DirectorySearcher(m_obDirEntry);
> //srch.Filter = "(objectClass=Members)";
> SearchResultCollection results;
> results=srch.FindAll();
> foreach (SearchResult result in results)
> {
> ResultPropertyCollection propColl=result.Properties;
> foreach (string strKey in propColl.PropertyNames)
> {
> foreach (object obProp in propColl[strKey])
> {
> Response.Write("name=" + obProp.GetType().ToString() +
> "Value=" + obProp.ToString()+"<br>");
> }
> }
> }
>
> From this code, I couldn't get the information I need. When I
opened
> 'Active Directory Users and Computers' from Win2K Advance Server,
there
> are several subfolders: Computers, Domain Controllers, Users...
When I
> selected 'Users', there are subfolders such as: Administrators,
Domain
> Users,.... I double click on 'Domain Users', the 'Domain Users
> Properties' dialog box shows, when I selected 'Members' tab, I got
a
> list of user names. I doubleclick on my names, '...Properties'
dialog
> box shows, I can find my email address under 'General' tab.
>
> My question is, how can I get to full name and the email address
> properties and retrieve them?
>
> Thanks a lot!
>
> Shan
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now
>
> [Non-text portions of this message have been removed]
>
>
>
> To unsubscribe from this group, send an email to:
> ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
> ----------
>
> -------------------------------------------------------------
> This email and any files transmitted are
> confidential and intended solely for the
> use of the individual or entity to which
> they are addressed, whose privacy
> should be respected. Any views or
> opinions are solely those of the author
> and do not necessarily represent those
> of the Trencor Group, or any of its
> representatives, unless specifically
> stated.
>
> Email transmission cannot be guaranteed
> to be secure, error free or without virus
> contamination. The sender therefore
> accepts no liability for any errors or
> omissions in the contents of this message,
> nor for any virus infection that might result
> from opening this message. Trencor is not
> responsible in the event of any third party
> interception of this email.
>
> If you have received this email in error please notify
> postmaster@t... For more information about
> Trencor, visit www.trencor.net <http://www.trencor.net>
>
>
>
> [Non-text portions of this message have been removed]
I just need to ask you why are you trying to use this type of "SQL query" to
the LDAP directory?
It would be much simpler to use normal ADSI and or DirectoryServices wouldnt
it?
Here is a brilliant article to show you and explain how to bind to both
printers on NT4 and or Ldap directories and retirve information.
have a look and let us know if it helped
http://www.winscriptingsolutions.com/Articles/Index.cfm?ArticleID=6128
p.s. Dont worry about the post length ;-)
HTH
CM
-----Original Message-----
From: eyuzwa <wazoo@...>
To: ADSIANDDirectoryServices@yahoogroups.com
Sent: 2/10/03 10:28 PM
Subject: [ADSIANDDirectoryServices] Re: getting stuck querying LDAP provider
with SQL
Hi Carlos,
thanks for the quick reply!
Okay here's how I'm doing it with some VBScript inside an ASP page.
[begin source]
Dim objConn, objCommand, objRS
Set objConn = Server.CreateObject("ADODB.Connection")
With objConn
.Provider = "ADsDSOObject"
.Properties("User Id") = user
.Properties("Password")= pwd
End With
objConn.Open "ADs Provider"
Set objCommand = Server.CreateObject("ADODB.Command")
With objCommand
.ActiveConnection = objConn
.CommandText = "SELECT cn from
'LDAP://<server>/dc=<domain>,dc=com'
WHERE objectClass='printQueue'"
End With
Set objRS = objCommand.Execute
[end source]
Hopefully that all came through on HTML properly..;)
Now the problem is that I'm trying to request/display some attributes
for each printer in the printerQueue (ie. printerName, location, etc).
Using "normal" SQL, I would just specify the column name I need in the
result set in the query...
ie. SELECT printerName, cn from 'LDAP://<server>/dc=<domain>,dc=com'
WHERE objectClass='printQueue'
but it just blows up. :(
Thanks for any advice, and I apologize for the long post here..
--- In ADSIANDDirectoryServices@yahoogroups.com, "Carlos Magalhaes
<CarlosM@t...>" <CarlosM@t...> wrote:
> Hello ,
>
> This is interesting, can you show us a bit more code from your
> example so that we can see how you are actually interfacing to the
> directory.
>
> This will help us identify the problem, and technology you are
using,
> i.e. DirectoryServices ADSI , VbScript, Vb.NEt C# this all makes a
> bit of a diffrence.
>
> Thanks
>
> Carlos
>
>
> --- In ADSIANDDirectoryServices@yahoogroups.com, "eyuzwa
> <wazoo@w...>" <wazoo@w...> wrote:
> > Hi all,
> >
> > I'm trying to use a SQL query type approach for querying our LDAP
> > server, but I'm getting stuck trying to figure out how to retrieve
> > some attributes..
> >
> > ie. (for an .asp page)
> >
> > .CommandText = "SELECT cn from 'LDAP://<server>' WHERE
> > objectClass='printQueue'"
> >
> > I've got the above query properly working, but I NEED to also grab
> > attributes like the "printerName" or "location", etc..
> >
> > however if I try out..
> >
> > .CommandText = "SELECT printerName from 'LDAP://<server>' WHERE
> > objectClass='printQueue'"
> >
> > I get some "Unspecified Error" messages on my browser..
> >
> > Any advice would be appreciated!
To unsubscribe from this group, send an email to:
ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
Hi Carlos,
thanks for the quick reply!
Okay here's how I'm doing it with some VBScript inside an ASP page.
[begin source]
Dim objConn, objCommand, objRS
Set objConn = Server.CreateObject("ADODB.Connection")
With objConn
.Provider = "ADsDSOObject"
.Properties("User Id") = user
.Properties("Password")= pwd
End With
objConn.Open "ADs Provider"
Set objCommand = Server.CreateObject("ADODB.Command")
With objCommand
.ActiveConnection = objConn
.CommandText = "SELECT cn from 'LDAP://<server>/dc=<domain>,dc=com'
WHERE objectClass='printQueue'"
End With
Set objRS = objCommand.Execute
[end source]
Hopefully that all came through on HTML properly..;)
Now the problem is that I'm trying to request/display some attributes
for each printer in the printerQueue (ie. printerName, location, etc).
Using "normal" SQL, I would just specify the column name I need in the
result set in the query...
ie. SELECT printerName, cn from 'LDAP://<server>/dc=<domain>,dc=com'
WHERE objectClass='printQueue'
but it just blows up. :(
Thanks for any advice, and I apologize for the long post here..
--- In ADSIANDDirectoryServices@yahoogroups.com, "Carlos Magalhaes
<CarlosM@t...>" <CarlosM@t...> wrote:
> Hello ,
>
> This is interesting, can you show us a bit more code from your
> example so that we can see how you are actually interfacing to the
> directory.
>
> This will help us identify the problem, and technology you are
using,
> i.e. DirectoryServices ADSI , VbScript, Vb.NEt C# this all makes a
> bit of a diffrence.
>
> Thanks
>
> Carlos
>
>
> --- In ADSIANDDirectoryServices@yahoogroups.com, "eyuzwa
> <wazoo@w...>" <wazoo@w...> wrote:
> > Hi all,
> >
> > I'm trying to use a SQL query type approach for querying our LDAP
> > server, but I'm getting stuck trying to figure out how to retrieve
> > some attributes..
> >
> > ie. (for an .asp page)
> >
> > .CommandText = "SELECT cn from 'LDAP://<server>' WHERE
> > objectClass='printQueue'"
> >
> > I've got the above query properly working, but I NEED to also grab
> > attributes like the "printerName" or "location", etc..
> >
> > however if I try out..
> >
> > .CommandText = "SELECT printerName from 'LDAP://<server>' WHERE
> > objectClass='printQueue'"
> >
> > I get some "Unspecified Error" messages on my browser..
> >
> > Any advice would be appreciated!
Hello ,
This is interesting, can you show us a bit more code from your
example so that we can see how you are actually interfacing to the
directory.
This will help us identify the problem, and technology you are using,
i.e. DirectoryServices ADSI , VbScript, Vb.NEt C# this all makes a
bit of a diffrence.
Thanks
Carlos
--- In ADSIANDDirectoryServices@yahoogroups.com, "eyuzwa
<wazoo@w...>" <wazoo@w...> wrote:
> Hi all,
>
> I'm trying to use a SQL query type approach for querying our LDAP
> server, but I'm getting stuck trying to figure out how to retrieve
> some attributes..
>
> ie. (for an .asp page)
>
> .CommandText = "SELECT cn from 'LDAP://<server>' WHERE
> objectClass='printQueue'"
>
> I've got the above query properly working, but I NEED to also grab
> attributes like the "printerName" or "location", etc..
>
> however if I try out..
>
> .CommandText = "SELECT printerName from 'LDAP://<server>' WHERE
> objectClass='printQueue'"
>
> I get some "Unspecified Error" messages on my browser..
>
> Any advice would be appreciated!
Hey Shan,
I noticed that you did request a VB.NET example in the previous post on a
diffrent group before you posted here so here is a vb.net example that will
display, Property Names and all the properties values.
You just have to read through the code and set the relevant parts according
to your domain.
System.DirectoryServices.DirectoryEntry
("LDAP://servername/o=org/ou=members/ou=somememeber")
Dim mySearcher As New DirectorySearcher(oDirectory)
Dim oDirEntry As DirectoryEntry
Dim oPropNames As ICollection
Dim oProperties As DirectoryServices.PropertyCollection
Dim oPropValues As PropertyValueCollection
Dim oValue As Object
Dim oResult As SearchResult
Dim sPropName As String
mySearcher.SearchScope = SearchScope.Subtree
mySearcher.ReferralChasing = ReferralChasingOption.All
mySearcher.Filter = "([use an ldap filter here])"
Try
For Each oResult In mySearcher.FindAll
oDirEntry = oResult.GetDirectoryEntry
Debug.WriteLine(oDirEntry.Path)
oProperties = oDirEntry.Properties
For Each sPropName In
oProperties.PropertyNames
Debug.WriteLine(sPropName & "=")
oPropValues = oProperties(sPropName)
For Each oValue In oPropValues
Debug.WriteLine(" " &
oValue.ToString)
Next
Next
Next
Debug.WriteLine("done")
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
If this is not what you looking for please let us know and you will have to
modify this a little bit to work on a asp.net web page but if you need help
doing that just let us know.
If you are actually needing this in C# please also let us know.
HTH
Carlos
-----Original Message-----
From: Shan Wang
To: ADSIANDDirectoryServices@yahoogroups.com
Sent: 2/10/03 5:45 PM
Subject: [ADSIANDDirectoryServices] Access Active Directory for User Full
Name and Email Address
Hi, all,
I am new to Active Directory programming. I want to access Active
Directory for user full name and email address, but I couldn't get them.
My code to access Active Directory is the following:
private void Page_Load(object sender, System.EventArgs e)
{
string strLDAP=LDAP://CN=Domain
Users,CN=Users,DC=Mydomain,DC=com;
DirectoryEntry m_obDirEntry=new DirectoryEntry(strLDAP);
DirectorySearcher srch=new DirectorySearcher(m_obDirEntry);
//srch.Filter = "(objectClass=Members)";
SearchResultCollection results;
results=srch.FindAll();
foreach (SearchResult result in results)
{
ResultPropertyCollection propColl=result.Properties;
foreach (string strKey in propColl.PropertyNames)
{
foreach (object obProp in propColl[strKey])
{
Response.Write("name=" + obProp.GetType().ToString() +
"Value=" + obProp.ToString()+"<br>");
}
}
}
From this code, I couldn't get the information I need. When I opened
'Active Directory Users and Computers' from Win2K Advance Server, there
are several subfolders: Computers, Domain Controllers, Users... When I
selected 'Users', there are subfolders such as: Administrators, Domain
Users,.... I double click on 'Domain Users', the 'Domain Users
Properties' dialog box shows, when I selected 'Members' tab, I got a
list of user names. I doubleclick on my names, '...Properties' dialog
box shows, I can find my email address under 'General' tab.
My question is, how can I get to full name and the email address
properties and retrieve them?
Thanks a lot!
Shan
---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
[Non-text portions of this message have been removed]
To unsubscribe from this group, send an email to:
ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
Hi all,
I'm trying to use a SQL query type approach for querying our LDAP
server, but I'm getting stuck trying to figure out how to retrieve
some attributes..
ie. (for an .asp page)
.CommandText = "SELECT cn from 'LDAP://<server>' WHERE
objectClass='printQueue'"
I've got the above query properly working, but I NEED to also grab
attributes like the "printerName" or "location", etc..
however if I try out..
.CommandText = "SELECT printerName from 'LDAP://<server>' WHERE
objectClass='printQueue'"
I get some "Unspecified Error" messages on my browser..
Any advice would be appreciated!
Hi, all,
I am new to Active Directory programming. I want to access Active Directory for
user full name and email address, but I couldn't get them. My code to access
Active Directory is the following:
private void Page_Load(object sender, System.EventArgs e)
{
string strLDAP=LDAP://CN=Domain Users,CN=Users,DC=Mydomain,DC=com;
DirectoryEntry m_obDirEntry=new DirectoryEntry(strLDAP);
DirectorySearcher srch=new DirectorySearcher(m_obDirEntry);
//srch.Filter = "(objectClass=Members)";
SearchResultCollection results;
results=srch.FindAll();
foreach (SearchResult result in results)
{
ResultPropertyCollection propColl=result.Properties;
foreach (string strKey in propColl.PropertyNames)
{
foreach (object obProp in propColl[strKey])
{
Response.Write("name=" + obProp.GetType().ToString() + "Value=" +
obProp.ToString()+"<br>");
}
}
}
From this code, I couldn't get the information I need. When I opened 'Active
Directory Users and Computers' from Win2K Advance Server, there are several
subfolders: Computers, Domain Controllers, Users... When I selected 'Users',
there are subfolders such as: Administrators, Domain Users,.... I double click
on 'Domain Users', the 'Domain Users Properties' dialog box shows, when I
selected 'Members' tab, I got a list of user names. I doubleclick on my names,
'...Properties' dialog box shows, I can find my email address under 'General'
tab.
My question is, how can I get to full name and the email address properties and
retrieve them?
Thanks a lot!
Shan
---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
[Non-text portions of this message have been removed]
Jason,
The code samples will be in both in VB.NET and C#, unless there is a
request(s) to have only one language in the articles.
Why what language would you like to see the article in?
Regards,
Carlos Magalhaes
-----Original Message-----
From: Jason Gaylord [mailto:jgaylord@...]
Sent: Saturday, February 08, 2003 4:09 PM
To: ADSIANDDirectoryServices@yahoogroups.com
Subject: Re: [ADSIANDDirectoryServices] Ideas for more articles
Carlos,
Are you doing this in VB or C#?
Jason
---------- Original Message ----------------------------------
From: Carlos Magalhaes <CarlosM@...>
Reply-To: ADSIANDDirectoryServices@yahoogroups.com
Date: Fri, 7 Feb 2003 15:04:10 +0200
><html><body>
>
>
><tt>
>Hi all,<BR>
><BR>
> <BR>
><BR>
>As I am coming closer to completing the first in a 4 part article and<BR>
>posting it, I want to make sure I don't leave anything out that any of
you<BR>
>out there want to know or want to have explained. This will help me
research<BR>
>the problems and find answers for all those unanswered questions you
all<BR>
>might have. I had a request to have a section/part in my article showing
all<BR>
>you wonderful people how to create a "Search Porthole" using asp.net,
for<BR>
>users wanting to retrieve information on your colleagues in your
company.<BR>
>Ideas and suggestions are most welcome.<BR>
><BR>
> <BR>
><BR>
>Please post your ideas and thoughts.<BR>
><BR>
> <BR>
><BR>
>Thanks<BR>
><BR>
> <BR>
><BR>
>Regards,<BR>
><BR>
>Carlos<BR>
><BR>
><BR>
> ----------<BR>
><BR>
>-------------------------------------------------------------<BR>
>This email and any files transmitted are<BR>
>confidential and intended solely for the<BR>
>use of the individual or entity to which<BR>
>they are addressed, whose privacy<BR>
>should be respected. Any views or<BR>
>opinions are solely those of the author<BR>
>and do not necessarily represent those<BR>
>of the Trencor Group, or any of its<BR>
>representatives, unless specifically<BR>
>stated. <BR>
><BR>
>Email transmission cannot be guaranteed<BR>
>to be secure, error free or without virus<BR>
>contamination. The sender therefore<BR>
>accepts no liability for any errors or<BR>
>omissions in the contents of this message,<BR>
>nor for any virus infection that might result<BR>
>from opening this message. Trencor is not<BR>
>responsible in the event of any third party<BR>
>interception of this email. <BR>
><BR>
>If you have received this email in error please notify<BR>
>postmaster@... For more information about<BR>
>Trencor, visit www.trencor.net <<a
href="http://www.trencor.net">http://www.trencor.net</a>><BR>
><BR>
><BR>
><BR>
>[Non-text portions of this message have been removed]<BR>
><BR>
></tt>
>
>
><br>
><tt>
>To unsubscribe from this group, send an email to:<BR>
>ADSIANDDirectoryServices-unsubscribe@yahoogroups.com<BR>
><BR>
></tt>
><br>
>
><br>
><tt>Your use of Yahoo! Groups is subject to the <a
href="http://docs.yahoo.com/info/terms/">Yahoo! Terms of Service</a>.</tt>
></br>
>
></body></html>
>
>
To unsubscribe from this group, send an email to:
ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
Carlos,
Are you doing this in VB or C#?
Jason
---------- Original Message ----------------------------------
From: Carlos Magalhaes <CarlosM@...>
Reply-To: ADSIANDDirectoryServices@yahoogroups.com
Date: Fri, 7 Feb 2003 15:04:10 +0200
><html><body>
>
>
><tt>
>Hi all,<BR>
><BR>
> <BR>
><BR>
>As I am coming closer to completing the first in a 4 part article and<BR>
>posting it, I want to make sure I don't leave anything out that any of you<BR>
>out there want to know or want to have explained. This will help me
research<BR>
>the problems and find answers for all those unanswered questions you all<BR>
>might have. I had a request to have a section/part in my article showing
all<BR>
>you wonderful people how to create a "Search Porthole" using asp.net, for<BR>
>users wanting to retrieve information on your colleagues in your company.<BR>
>Ideas and suggestions are most welcome.<BR>
><BR>
> <BR>
><BR>
>Please post your ideas and thoughts.<BR>
><BR>
> <BR>
><BR>
>Thanks<BR>
><BR>
> <BR>
><BR>
>Regards,<BR>
><BR>
>Carlos<BR>
><BR>
><BR>
> ----------<BR>
><BR>
>-------------------------------------------------------------<BR>
>This email and any files transmitted are<BR>
>confidential and intended solely for the<BR>
>use of the individual or entity to which<BR>
>they are addressed, whose privacy<BR>
>should be respected. Any views or<BR>
>opinions are solely those of the author<BR>
>and do not necessarily represent those<BR>
>of the Trencor Group, or any of its<BR>
>representatives, unless specifically<BR>
>stated. <BR>
><BR>
>Email transmission cannot be guaranteed<BR>
>to be secure, error free or without virus<BR>
>contamination. The sender therefore<BR>
>accepts no liability for any errors or<BR>
>omissions in the contents of this message,<BR>
>nor for any virus infection that might result<BR>
>from opening this message. Trencor is not<BR>
>responsible in the event of any third party<BR>
>interception of this email. <BR>
><BR>
>If you have received this email in error please notify<BR>
>postmaster@... For more information about<BR>
>Trencor, visit www.trencor.net <<a
href="http://www.trencor.net">http://www.trencor.net</a>><BR>
><BR>
><BR>
><BR>
>[Non-text portions of this message have been removed]<BR>
><BR>
></tt>
>
>
><br>
><tt>
>To unsubscribe from this group, send an email to:<BR>
>ADSIANDDirectoryServices-unsubscribe@yahoogroups.com<BR>
><BR>
></tt>
><br>
>
><br>
><tt>Your use of Yahoo! Groups is subject to the <a
href="http://docs.yahoo.com/info/terms/">Yahoo! Terms of Service</a>.</tt>
></br>
>
></body></html>
>
>
Hi all,
As I am coming closer to completing the first in a 4 part article and
posting it, I want to make sure I don't leave anything out that any of you
out there want to know or want to have explained. This will help me research
the problems and find answers for all those unanswered questions you all
might have. I had a request to have a section/part in my article showing all
you wonderful people how to create a "Search Porthole" using asp.net, for
users wanting to retrieve information on your colleagues in your company.
Ideas and suggestions are most welcome.
Please post your ideas and thoughts.
Thanks
Regards,
Carlos
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
<CarlosM@... is posting this on Behalf of
John.Mirochnik@...>
Hi,
I installed MS EXchange 2000 on the web server and tried running an
asp
that
reads mailbox permissions:
<%
.....
UserObject.MailboxRights
.......
%>
but I get error below:
An invalid ADSI pathname was passed. ID no: 80005000 Microsoft CDO
for
Exchange Management
however when I run exactly the same code in a .vbs file then I don't
have
any problems. In the asp I check if i can retrieve other user
properties
of
the UserObject for ex: response.write(UserObject.Name) and I can so I
can
connect to user account successfuly. Does anyone know what the
problem
is?
The rest of the code is:
Set LDAPNS=GetObject("LDAP:")
Set objPerson = LDAPNS.OpenDSObject("LDAP://" & LDAPHost & ":" &
LDAPPort & "/" & OBJ_DN, myid, password, 0)
Set sd=objPerson.MailboxRights
Set dacl = sd.DiscretionaryAcl
for each ac in dacl
'in asp file its response.write(ac.Trustee & "|" & ac.AceType & "|" &
ac.AceFlags & "|" & ac.AccessMask)
msgbox ac.Trustee & "|" & ac.AceType & "|" & ac.AceFlags & "|" &
ac.AccessMask
next
'''I used to do this for Exchange 5.5 (msExchSecurityDescriptor)
object and it worked fine in both asp and vbs, but
in 2000 its MailboxRights function (part of CDO) that replaced
msExchSecurityDescriptor. I have Exch2000 SP2.
I hit the RUS error , but read Srividya post with that link before you
posted) and it also gave a few pointers, and a diffrent way to do it.
Check that link out...
Thank you though for your example it was EXACTLY what i needed ;-)
-----Original Message-----
From: Mark Dewell
To: ADSIANDDirectoryServices@yahoogroups.com
Sent: 2/6/03 5:09 PM
Subject: RE: [ADSIANDDirectoryServices] Creating E2K Mailbox with Directory
Services
Ooops forgot a bit. The earlier code will work, but RUS fails to set the
correct security permissions and the user will not be able access public
folders - although their own personal mailbox access will be ok. Append
these
3 lines to my earlier code to ensure correct security permissions are
set by
RUS.
Set ObjMailbox = objUser
ObjMailbox.CreateMailbox UserMailStore
objUser.SetInfo 'commit properties to ADS
> -----Original Message-----
> From: Mark Dewell [mailto:m.dewell@...]
> Sent: 06 February 2003 15:02
> To: ADSIANDDirectoryServices@yahoogroups.com
> Subject: RE: [ADSIANDDirectoryServices] Creating E2K Mailbox
> with Directory Services
>
>
> Create the user as usual and then set the following
> properties on the user
> object. The Reciepient Update Service will take care of the rest.
>
> wscript.echo "Now setting exchange system properties."
> WScript.Echo " "
> objUser.homeMDB = UserMailStore
> objUser.mail = userName & "@xyz.co.uk"
> objUser.mailNickname = userName
> objUser.mDBUseDefaults = TRUE
> objUser.SetInfo 'commit properties to ADS
>
> UserMailStore is the ADS path to the mail store database
> (e.g.
> CN=StaffStore,CN=StaffGroup,CN=InformationStore,CN=MAILSVR1,CN
> =Servers,CN=Fir
> st Admin Group,CN=Administrative Groups,CN=UEL-Exchange,CN=Microsoft
> Exchange,CN=Services,CN=Configuration,DC=xyz,DC=co,DC=uk )
>
> > -----Original Message-----
> > From: Carlos Magalhaes [mailto:CarlosM@...]
> > Sent: 06 February 2003 14:39
> > To: ADSIANDDirectoryServices@yahoogroups.com
> > Subject: [ADSIANDDirectoryServices] Creating E2K Mailbox with
> > Directory Services
> >
> >
> > Does anyone have information on how to create a E2K Mailbox
> > with Directory
> > Services.
> >
> >
> >
> > Let me know.
> >
> >
> >
> > CM
> >
> >
> > ----------
> >
> > -------------------------------------------------------------
> > This email and any files transmitted are
> > confidential and intended solely for the
> > use of the individual or entity to which
> > they are addressed, whose privacy
> > should be respected. Any views or
> > opinions are solely those of the author
> > and do not necessarily represent those
> > of the Trencor Group, or any of its
> > representatives, unless specifically
> > stated.
> >
> > Email transmission cannot be guaranteed
> > to be secure, error free or without virus
> > contamination. The sender therefore
> > accepts no liability for any errors or
> > omissions in the contents of this message,
> > nor for any virus infection that might result
> > from opening this message. Trencor is not
> > responsible in the event of any third party
> > interception of this email.
> >
> > If you have received this email in error please notify
> > postmaster@... For more information about
> > Trencor, visit www.trencor.net <http://www.trencor.net>
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> > ------------------------ Yahoo! Groups Sponsor
> > ---------------------~-->
> > Get 128 Bit SSL Encryption!
> > http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/saFolB/TM
> > --------------------------------------------------------------
> > -------~->
> >
> > To unsubscribe from this group, send an email to:
> > ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
> >
> >
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~-->
> Get 128 Bit SSL Encryption!
> http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/saFolB/TM
> --------------------------------------------------------------
> -------~->
>
> To unsubscribe from this group, send an email to:
> ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
To unsubscribe from this group, send an email to:
ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
Thank you , in a few days I will recode this using DirectoryServices (there
is absolutely nothing wrong with using straight ADSI just want to show
people how to do it in DS)and I will post it to the Group, thank you
Charles.
-----Original Message-----
From: Charles Oppermann
To: ADSIANDDirectoryServices@yahoogroups.com
Sent: 2/6/03 7:56 PM
Subject: RE: [ADSIANDDirectoryServices] Creating E2K Mailbox with Directory
Services
From my first book, using ADSI, not S.DS.
CreateUserWithMail.wsf
<job id="CreateUserWithMail">
<reference guid="{97D25DB0-0363-11CF-ABC4-02608C9E7553}"/>
<reference guid="{CD000000-8B95-11D1-82DB-00C04FB1625D}"/>
<script language="VBScript">
'
' CreateUserWithMail - Creates user and mailbox
'
' Chapter 10 Sample
' Microsoft Windows 2000 Active Directory Programming
' Copyright (C) 2001 Charles Oppermann
'
' NOTES:
' To work properly this script must be edited to use
' sender defaults in set in SendUserMessage function
'
' This script requires Windows 2000 or newer
'
' Strings used to identify and describe the new user
' Logon name
strUserAcct = "JAUser"
strFullName = "Joe A. User"
strFirstName = "Joe"
strLastName = "User"
strPassword = "defaultpassword"
' Lots of confusion on these. Wizard uses initials as a "middle
initial"
strMiddleName = "Average"
strInitials = "JAU"
' Descriptive info
strUserDesc = "Example user for testing purposes."
strTelephone = "888-555-1212"
strStreet = "One Microsoft Way"
strCity = "Redmond"
strState = "WA"
strZIPCode = "98052"
' Display info
WScript.Echo "Creating new user '" & strFullName & "'..."
' Bind to the rootDSE and get the default domain partion
Set adsRootDSE = GetObject("LDAP://rootDSE")
strDomainDN = adsRootDSE.Get("defaultNamingContext")
' Bind to the Users container of the domain
strADsPath = "LDAP://CN=Users," & strDomainDN
Set adsContainer = GetObject(strADsPath)
' Turn on error handling
On Error Resume Next
' Create the object in the container using the full user name
Set adsUser = adsContainer.Create("user", "cn=" + strFullName)
' Set the down-level account name for the user (<20 characters)
adsUser.Put "sAMAccountName", strUserAcct
' Set the UPN for the user
adsUser.Put "userPrincipalName", strUserAcct
' Update server with required properties
adsUser.SetInfo
' Check for errors
If Err.Number <> 0 Then
' Check to see if user already exists error
If Err.Number = &H80071392 Then
' Display error message and exit
WScript.Echo "The user name '" & strFullName & "'
already
exists."
WScript.Quit 1
Else
WScript.Echo "Unexpected error creating user." &
vbNewLine &
Err.Description & " (" & Hex(Err.Number) & ")"
WScript.Quit 1
End If
End If
' Turn off error handling
On Error GoTo 0
' Use IADsUser properties to set other pieces of data
' Refresh the local property cache with new user info
adsUser.GetInfo
' Set the user password. SetInfo must be called beforehand (above)
adsUser.SetPassword strPassword
' Require the user to change their password on login
adsUser.Put "pwdLastSet", 0
' Enable the account (default when created is disabled)
adsUser.AccountDisabled = vbFalse
' Set the display name of the user
adsUser.FullName = strFullName
' Set name information of the user
adsUser.FirstName = strFirstName
adsUser.LastName = strLastName
adsUser.OtherName = strMiddleName
adsUser.Put "initials", strInitials
' Set the description using the Description property
adsUser.Description = strUserDesc
' Set the telephone number
adsUser.TelephoneNumber = strTelephone
' Set the address information
' Must use Active Directory attributes, not PostalAddress property.
adsUser.Put "streetAddress", strStreet
adsUser.Put "l", strCity
adsUser.Put "st", strState
adsUser.Put "postalCode", strZIPCode
' Set the e-mail address using account and domain names
strEmailAddress = strUserAcct & "@" & GetDomainDNSName( adsRootDSE )
' Give the user an e-mail address
adsUser.mail = strEmailAddress
' Apply the properties to the directory
adsUser.SetInfo
' Create Exchange 2000 mailbox for user
WScript.Echo "Creating mailbox for user..."
' *** Change to your own Exchange 2000 Server ***
' Set the Exchange 2000 server name
' Default will use current DC
strExServer = adsRootDSE.dnsHostName
' Call function to create mailbox
Call CreateMailbox(adsUser, strExServer)
' Send a welcome message
Call SendUserMessage(adsUser, "Welcome", "Welcome to our network")
' Finish
WScript.Echo "Finished."
'------------------------------------------------
' Create Mailbox for user on Exchange 2000 Server
'------------------------------------------------
Public Function CreateMailbox( adsUser, strExServer )
' Save off the existing e-mail address
' It will get replaced by Exchange 2000
strAddress = adsUser.EmailAddress
' Get the CDOEXM interface using
' ADSI Extensions
Set cdoExMailbox = adsUser
' Get the path to the Mailbox store
strMailBoxPath = MBStorePath(strExServer)
' Use IMailboxStore to create mailbox for this user
cdoExMailbox.CreateMailbox strMailBoxPath
' Set the initial e-mail address
cdoExMailbox.SMTPEmail = strAddress
' Must commit before mailbox is created
adsUser.SetInfo
' Cleanup
Set cdoExMailbox = Nothing
End Function
'------------------------------------------------
' Get the Mailbox store ADsPath
'------------------------------------------------
Public Function MBStorePath( strExServer )
' Create the CDOEXM objects we'll need
Set cdoExMServer = CreateObject("CDOEXM.ExchangeServer")
Set cdoExMStorageGroup = CreateObject("CDOEXM.StorageGroup")
Set cdoExMMailboxStore = CreateObject("CDOEXM.MailboxStoreDB")
' Open a connection to the server
Set cdoDS2 = cdoExMServer.DataSource
cdoDS2.Open strExServer
' Get each storage group on this server
For Each varStorageGroup In cdoExMServer.StorageGroups
' Open this storage group
cdoExMStorageGroup.DataSource.Open varStorageGroup
' Enumerate the mailbox stores
For Each varMailboxStore In cdoExMStorageGroup.MailboxStoreDBs
' Open this store to access fields
cdoExMMailboxStore.DataSource.Open varMailboxStore
If (cdoExMMailboxStore.Enabled = True) Then
' Return the name of the mailbox store on this server
MBStorePath = "LDAP://" & varMailboxStore
End If
Next
Next
' Release objects no longer needed
Set cdoExMServer = Nothing
Set cdoExMStorageGroup = Nothing
Set cdoExMMailboxStore = Nothing
End Function
'------------------------
' Send the user a message
'------------------------
Public Function SendUserMessage( adsUser, strSubject, strText)
' Create a blank message
Set cdoMessage = CreateObject("CDO.Message")
' Set the address of who to send this message to
cdoMessage.To = adsUser.EmailAddress
WScript.Echo "Sending message to " & adsUser.EmailAddress
' Set the subject
cdoMessage.Subject = strSubject
' Set the text of the message
cdoMessage.TextBody = strText
'*** IMPORTANT ***
'*** MUST CHANGE THE FOLLOWING TO YOU OWN VALUES***
' Name and e-mail address of sender
cdoMessage.Configuration.Fields(CdoConfiguration.cdoSendEmailAddress) =
"""Charles Oppermann"" <charles@...>"
' Send using SMTP port
cdoMessage.Configuration.Fields(CdoConfiguration.cdoSendUsingMethod) =
cdoSendUsingPort
cdoMessage.Configuration.Fields(CdoConfiguration.cdoSMTPServerPort) = 25
' Set NTLM challenge and response to send message
cdoMessage.Configuration.Fields(CdoConfiguration.cdoSMTPAuthenticate) =
cdoNTLM
cdoMessage.Configuration.Fields(CdoConfiguration.cdoSMTPServer) =
"copper1"
' Update the message with the new sender values
cdoMessage.Configuration.Fields.Update
' Send the message
cdoMessage.Send
End Function
'--------------------------------
' Get the DNS name for the domain
'--------------------------------
Public Function GetDomainDNSName( adsRootDSE )
' Bind to the default domain to get name
Set adsDomain = GetObject("LDAP://" &
adsRootDSE.Get("defaultNamingContext"))
' Use NameTraslate to lookup the group in the directory
Set adsNameTranslate = CreateObject("NameTranslate")
' Specify the GC for quick lookups
adsNameTranslate.Init ADS_NAME_INITTYPE_GC, vbNull
' Set the DN of the domain
adsNameTranslate.Set ADS_NAME_TYPE_1779, adsRootDSE.defaultNamingContext
' Get the domain DNS address
' For some reason, it's returned with an extra character
strDomainDNS = adsNameTranslate.Get(ADS_NAME_TYPE_CANONICAL_EX)
' Form an e-mail name without the extra character
GetDomainDNSName = Left(strDomainDNS, Len(strDomainDNS) - 1)
' Clean up
Set adsDomain = Nothing
Set adsNameTranslate = Nothing
End Function
</script>
</job>
Charles Oppermann, Copper Software
Author, "Microsoft Windows 2000 Active Directory Programming"
http://www.coppersoftware.com/activedir/
-----Original Message-----
From: Carlos Magalhaes [mailto:CarlosM@...]
Sent: Thursday, February 6, 2003 6:39 AM
To: 'ADSIANDDirectoryServices@yahoogroups.com'
Subject: [ADSIANDDirectoryServices] Creating E2K Mailbox with Directory
Services
Does anyone have information on how to create a E2K Mailbox with
Directory
Services.
[Non-text portions of this message have been removed]
To unsubscribe from this group, send an email to:
ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
From my first book, using ADSI, not S.DS.
CreateUserWithMail.wsf
<job id="CreateUserWithMail">
<reference guid="{97D25DB0-0363-11CF-ABC4-02608C9E7553}"/>
<reference guid="{CD000000-8B95-11D1-82DB-00C04FB1625D}"/>
<script language="VBScript">
'
' CreateUserWithMail - Creates user and mailbox
'
' Chapter 10 Sample
' Microsoft Windows 2000 Active Directory Programming
' Copyright (C) 2001 Charles Oppermann
'
' NOTES:
' To work properly this script must be edited to use
' sender defaults in set in SendUserMessage function
'
' This script requires Windows 2000 or newer
'
' Strings used to identify and describe the new user
' Logon name
strUserAcct = "JAUser"
strFullName = "Joe A. User"
strFirstName = "Joe"
strLastName = "User"
strPassword = "defaultpassword"
' Lots of confusion on these. Wizard uses initials as a "middle initial"
strMiddleName = "Average"
strInitials = "JAU"
' Descriptive info
strUserDesc = "Example user for testing purposes."
strTelephone = "888-555-1212"
strStreet = "One Microsoft Way"
strCity = "Redmond"
strState = "WA"
strZIPCode = "98052"
' Display info
WScript.Echo "Creating new user '" & strFullName & "'..."
' Bind to the rootDSE and get the default domain partion
Set adsRootDSE = GetObject("LDAP://rootDSE")
strDomainDN = adsRootDSE.Get("defaultNamingContext")
' Bind to the Users container of the domain
strADsPath = "LDAP://CN=Users," & strDomainDN
Set adsContainer = GetObject(strADsPath)
' Turn on error handling
On Error Resume Next
' Create the object in the container using the full user name
Set adsUser = adsContainer.Create("user", "cn=" + strFullName)
' Set the down-level account name for the user (<20 characters)
adsUser.Put "sAMAccountName", strUserAcct
' Set the UPN for the user
adsUser.Put "userPrincipalName", strUserAcct
' Update server with required properties
adsUser.SetInfo
' Check for errors
If Err.Number <> 0 Then
' Check to see if user already exists error
If Err.Number = &H80071392 Then
' Display error message and exit
WScript.Echo "The user name '" & strFullName & "' already
exists."
WScript.Quit 1
Else
WScript.Echo "Unexpected error creating user." & vbNewLine &
Err.Description & " (" & Hex(Err.Number) & ")"
WScript.Quit 1
End If
End If
' Turn off error handling
On Error GoTo 0
' Use IADsUser properties to set other pieces of data
' Refresh the local property cache with new user info
adsUser.GetInfo
' Set the user password. SetInfo must be called beforehand (above)
adsUser.SetPassword strPassword
' Require the user to change their password on login
adsUser.Put "pwdLastSet", 0
' Enable the account (default when created is disabled)
adsUser.AccountDisabled = vbFalse
' Set the display name of the user
adsUser.FullName = strFullName
' Set name information of the user
adsUser.FirstName = strFirstName
adsUser.LastName = strLastName
adsUser.OtherName = strMiddleName
adsUser.Put "initials", strInitials
' Set the description using the Description property
adsUser.Description = strUserDesc
' Set the telephone number
adsUser.TelephoneNumber = strTelephone
' Set the address information
' Must use Active Directory attributes, not PostalAddress property.
adsUser.Put "streetAddress", strStreet
adsUser.Put "l", strCity
adsUser.Put "st", strState
adsUser.Put "postalCode", strZIPCode
' Set the e-mail address using account and domain names
strEmailAddress = strUserAcct & "@" & GetDomainDNSName( adsRootDSE )
' Give the user an e-mail address
adsUser.mail = strEmailAddress
' Apply the properties to the directory
adsUser.SetInfo
' Create Exchange 2000 mailbox for user
WScript.Echo "Creating mailbox for user..."
' *** Change to your own Exchange 2000 Server ***
' Set the Exchange 2000 server name
' Default will use current DC
strExServer = adsRootDSE.dnsHostName
' Call function to create mailbox
Call CreateMailbox(adsUser, strExServer)
' Send a welcome message
Call SendUserMessage(adsUser, "Welcome", "Welcome to our network")
' Finish
WScript.Echo "Finished."
'------------------------------------------------
' Create Mailbox for user on Exchange 2000 Server
'------------------------------------------------
Public Function CreateMailbox( adsUser, strExServer )
' Save off the existing e-mail address
' It will get replaced by Exchange 2000
strAddress = adsUser.EmailAddress
' Get the CDOEXM interface using
' ADSI Extensions
Set cdoExMailbox = adsUser
' Get the path to the Mailbox store
strMailBoxPath = MBStorePath(strExServer)
' Use IMailboxStore to create mailbox for this user
cdoExMailbox.CreateMailbox strMailBoxPath
' Set the initial e-mail address
cdoExMailbox.SMTPEmail = strAddress
' Must commit before mailbox is created
adsUser.SetInfo
' Cleanup
Set cdoExMailbox = Nothing
End Function
'------------------------------------------------
' Get the Mailbox store ADsPath
'------------------------------------------------
Public Function MBStorePath( strExServer )
' Create the CDOEXM objects we'll need
Set cdoExMServer = CreateObject("CDOEXM.ExchangeServer")
Set cdoExMStorageGroup = CreateObject("CDOEXM.StorageGroup")
Set cdoExMMailboxStore = CreateObject("CDOEXM.MailboxStoreDB")
' Open a connection to the server
Set cdoDS2 = cdoExMServer.DataSource
cdoDS2.Open strExServer
' Get each storage group on this server
For Each varStorageGroup In cdoExMServer.StorageGroups
' Open this storage group
cdoExMStorageGroup.DataSource.Open varStorageGroup
' Enumerate the mailbox stores
For Each varMailboxStore In cdoExMStorageGroup.MailboxStoreDBs
' Open this store to access fields
cdoExMMailboxStore.DataSource.Open varMailboxStore
If (cdoExMMailboxStore.Enabled = True) Then
' Return the name of the mailbox store on this server
MBStorePath = "LDAP://" & varMailboxStore
End If
Next
Next
' Release objects no longer needed
Set cdoExMServer = Nothing
Set cdoExMStorageGroup = Nothing
Set cdoExMMailboxStore = Nothing
End Function
'------------------------
' Send the user a message
'------------------------
Public Function SendUserMessage( adsUser, strSubject, strText)
' Create a blank message
Set cdoMessage = CreateObject("CDO.Message")
' Set the address of who to send this message to
cdoMessage.To = adsUser.EmailAddress
WScript.Echo "Sending message to " & adsUser.EmailAddress
' Set the subject
cdoMessage.Subject = strSubject
' Set the text of the message
cdoMessage.TextBody = strText
'*** IMPORTANT ***
'*** MUST CHANGE THE FOLLOWING TO YOU OWN VALUES***
' Name and e-mail address of sender
cdoMessage.Configuration.Fields(CdoConfiguration.cdoSendEmailAddress) =
"""Charles Oppermann"" <charles@...>"
' Send using SMTP port
cdoMessage.Configuration.Fields(CdoConfiguration.cdoSendUsingMethod) =
cdoSendUsingPort
cdoMessage.Configuration.Fields(CdoConfiguration.cdoSMTPServerPort) = 25
' Set NTLM challenge and response to send message
cdoMessage.Configuration.Fields(CdoConfiguration.cdoSMTPAuthenticate) =
cdoNTLM
cdoMessage.Configuration.Fields(CdoConfiguration.cdoSMTPServer) = "copper1"
' Update the message with the new sender values
cdoMessage.Configuration.Fields.Update
' Send the message
cdoMessage.Send
End Function
'--------------------------------
' Get the DNS name for the domain
'--------------------------------
Public Function GetDomainDNSName( adsRootDSE )
' Bind to the default domain to get name
Set adsDomain = GetObject("LDAP://" &
adsRootDSE.Get("defaultNamingContext"))
' Use NameTraslate to lookup the group in the directory
Set adsNameTranslate = CreateObject("NameTranslate")
' Specify the GC for quick lookups
adsNameTranslate.Init ADS_NAME_INITTYPE_GC, vbNull
' Set the DN of the domain
adsNameTranslate.Set ADS_NAME_TYPE_1779, adsRootDSE.defaultNamingContext
' Get the domain DNS address
' For some reason, it's returned with an extra character
strDomainDNS = adsNameTranslate.Get(ADS_NAME_TYPE_CANONICAL_EX)
' Form an e-mail name without the extra character
GetDomainDNSName = Left(strDomainDNS, Len(strDomainDNS) - 1)
' Clean up
Set adsDomain = Nothing
Set adsNameTranslate = Nothing
End Function
</script>
</job>
Charles Oppermann, Copper Software
Author, "Microsoft Windows 2000 Active Directory Programming"
http://www.coppersoftware.com/activedir/
-----Original Message-----
From: Carlos Magalhaes [mailto:CarlosM@...]
Sent: Thursday, February 6, 2003 6:39 AM
To: 'ADSIANDDirectoryServices@yahoogroups.com'
Subject: [ADSIANDDirectoryServices] Creating E2K Mailbox with Directory
Services
Does anyone have information on how to create a E2K Mailbox with Directory
Services.
[Non-text portions of this message have been removed]
Ooops forgot a bit. The earlier code will work, but RUS fails to set the
correct security permissions and the user will not be able access public
folders - although their own personal mailbox access will be ok. Append these
3 lines to my earlier code to ensure correct security permissions are set by
RUS.
Set ObjMailbox = objUser
ObjMailbox.CreateMailbox UserMailStore
objUser.SetInfo 'commit properties to ADS
> -----Original Message-----
> From: Mark Dewell [mailto:m.dewell@...]
> Sent: 06 February 2003 15:02
> To: ADSIANDDirectoryServices@yahoogroups.com
> Subject: RE: [ADSIANDDirectoryServices] Creating E2K Mailbox
> with Directory Services
>
>
> Create the user as usual and then set the following
> properties on the user
> object. The Reciepient Update Service will take care of the rest.
>
> wscript.echo "Now setting exchange system properties."
> WScript.Echo " "
> objUser.homeMDB = UserMailStore
> objUser.mail = userName & "@xyz.co.uk"
> objUser.mailNickname = userName
> objUser.mDBUseDefaults = TRUE
> objUser.SetInfo 'commit properties to ADS
>
> UserMailStore is the ADS path to the mail store database
> (e.g.
> CN=StaffStore,CN=StaffGroup,CN=InformationStore,CN=MAILSVR1,CN
> =Servers,CN=Fir
> st Admin Group,CN=Administrative Groups,CN=UEL-Exchange,CN=Microsoft
> Exchange,CN=Services,CN=Configuration,DC=xyz,DC=co,DC=uk )
>
> > -----Original Message-----
> > From: Carlos Magalhaes [mailto:CarlosM@...]
> > Sent: 06 February 2003 14:39
> > To: ADSIANDDirectoryServices@yahoogroups.com
> > Subject: [ADSIANDDirectoryServices] Creating E2K Mailbox with
> > Directory Services
> >
> >
> > Does anyone have information on how to create a E2K Mailbox
> > with Directory
> > Services.
> >
> >
> >
> > Let me know.
> >
> >
> >
> > CM
> >
> >
> > ----------
> >
> > -------------------------------------------------------------
> > This email and any files transmitted are
> > confidential and intended solely for the
> > use of the individual or entity to which
> > they are addressed, whose privacy
> > should be respected. Any views or
> > opinions are solely those of the author
> > and do not necessarily represent those
> > of the Trencor Group, or any of its
> > representatives, unless specifically
> > stated.
> >
> > Email transmission cannot be guaranteed
> > to be secure, error free or without virus
> > contamination. The sender therefore
> > accepts no liability for any errors or
> > omissions in the contents of this message,
> > nor for any virus infection that might result
> > from opening this message. Trencor is not
> > responsible in the event of any third party
> > interception of this email.
> >
> > If you have received this email in error please notify
> > postmaster@... For more information about
> > Trencor, visit www.trencor.net <http://www.trencor.net>
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> > ------------------------ Yahoo! Groups Sponsor
> > ---------------------~-->
> > Get 128 Bit SSL Encryption!
> > http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/saFolB/TM
> > --------------------------------------------------------------
> > -------~->
> >
> > To unsubscribe from this group, send an email to:
> > ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> >
> >
> >
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~-->
> Get 128 Bit SSL Encryption!
> http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/saFolB/TM
> --------------------------------------------------------------
> -------~->
>
> To unsubscribe from this group, send an email to:
> ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
Create the user as usual and then set the following properties on the user
object. The Reciepient Update Service will take care of the rest.
wscript.echo "Now setting exchange system properties."
WScript.Echo " "
objUser.homeMDB = UserMailStore
objUser.mail = userName & "@xyz.co.uk"
objUser.mailNickname = userName
objUser.mDBUseDefaults = TRUE
objUser.SetInfo 'commit properties to ADS
UserMailStore is the ADS path to the mail store database
(e.g.
CN=StaffStore,CN=StaffGroup,CN=InformationStore,CN=MAILSVR1,CN=Servers,CN=Fir
st Admin Group,CN=Administrative Groups,CN=UEL-Exchange,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=xyz,DC=co,DC=uk )
> -----Original Message-----
> From: Carlos Magalhaes [mailto:CarlosM@...]
> Sent: 06 February 2003 14:39
> To: ADSIANDDirectoryServices@yahoogroups.com
> Subject: [ADSIANDDirectoryServices] Creating E2K Mailbox with
> Directory Services
>
>
> Does anyone have information on how to create a E2K Mailbox
> with Directory
> Services.
>
>
>
> Let me know.
>
>
>
> CM
>
>
> ----------
>
> -------------------------------------------------------------
> This email and any files transmitted are
> confidential and intended solely for the
> use of the individual or entity to which
> they are addressed, whose privacy
> should be respected. Any views or
> opinions are solely those of the author
> and do not necessarily represent those
> of the Trencor Group, or any of its
> representatives, unless specifically
> stated.
>
> Email transmission cannot be guaranteed
> to be secure, error free or without virus
> contamination. The sender therefore
> accepts no liability for any errors or
> omissions in the contents of this message,
> nor for any virus infection that might result
> from opening this message. Trencor is not
> responsible in the event of any third party
> interception of this email.
>
> If you have received this email in error please notify
> postmaster@... For more information about
> Trencor, visit www.trencor.net <http://www.trencor.net>
>
>
>
> [Non-text portions of this message have been removed]
>
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~-->
> Get 128 Bit SSL Encryption!
> http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/saFolB/TM
> --------------------------------------------------------------
> -------~->
>
> To unsubscribe from this group, send an email to:
> ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
Hi
To create an E2K mailbox you can use CDOEXM libraries along
with directory services or you can set the homeMDB property
of the user Object to mailbox store path where you want to create
the mailbox and mailalias..then the RUS (Recepient Update Service) from
E2K creates a mailbox.
See the below link for a sample with CDOEXM
http://support.microsoft.com/?id=313114
> Regards
> Srinivasulu N.S(RBIN;QI/ISS11)
> Kleyer Straße 94,
> Frankfurt.
> Phone : +49(69)7505 2427
-----Original Message-----
From: Carlos Magalhaes [mailto:CarlosM@...]
Sent: Thursday, February 06, 2003 3:39 PM
To: 'ADSIANDDirectoryServices@yahoogroups.com'
Subject: [ADSIANDDirectoryServices] Creating E2K Mailbox with Directory
Services
Does anyone have information on how to create a E2K Mailbox with Directory
Services.
Let me know.
CM
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
To unsubscribe from this group, send an email to:
ADSIANDDirectoryServices-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Does anyone have information on how to create a E2K Mailbox with Directory
Services.
Let me know.
CM
----------
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
[Non-text portions of this message have been removed]
Just had a hard time with this, so I figured I would post it because
it might save someone some headaches...
Win2k SP3 apparently fixes a bug that caused problems when trying to
read schema info from 3rd party LDAP's like IPlanet or Secureway...
Our ADSI code has been working for a year, so we never knew there
really was a bug... When we ran SP3 our ADSI code broke...
So, after a call to Microsoft we figured out that our code was kind
of a work-around for the original bug that we didn't even know
existed. So when it was fixed in SP3, our code broke.
The guys at MS gave me this:
http://support.microsoft.com/default.aspx?scid=kb;en-us;311512
which mentions the bug, and says upgrade the SP to fix it.
It was a pretty frustrating day, but we got it working again and I
figured I would post this to save folks from the same headaches. If
your ADSI code breaks after the SP3 install you know why now.
Chris
If you are running this as Anonymous Access site, the only way to get
access to AD is to either impersonate and change IUSR_Machinename to domain user,
or bind explicity with known account for DirectoryEntry.
If you are running this IWA, then you can use Kerberos delegation if
you are Win2k native domain. This will run the page with whatever credentials the
logged on user has. It requires the impersonation tag in your web.config.
One way of doing this is to remove the impersonate setting in web.config
and then allow the ASPNET process to run under a domain account. I had to modfiy
the processmodel section in machine.config.
I don't like this solution, however, because I want the applicaiton to
run under the credentials of the user that has authenticated to the page.
Here are a few functions that return "NotImplemented" names
:
<I>
objContainer =3D new DirectoryEntry("LDAP://cn=3Dusers," + =
DirectorySearcher
ds = new DirectorySearcher(_de, sFilter, new string[]{"memberOf"});
//find it
SearchResult
sr = ds.FindOne();
StringBuilder
sb = new StringBuilder();
try
{
if(sr!=null)
{
if(sr.Properties.Contains("memberOf"))
{
foreach(object o in sr.Properties["memberOf"])
{
sb.Append(o.ToString().Split(new char[]{','})[0].Split(new char[]{'='})[1]);
//grab the group cn
sb.Append(";");
}
}
}
else
throw new Exception("User Not Found.");
}
catch(Exception
ex)
{
throw new Exception("Error getting group information. " + ex.Message,
ex);
}
return
sb.ToString();
}
}
Realize that this will search wherever the DirectoryEntry has bound to
(and children containers). For best results, bind as close to your users
container as possible (less searching). You might also want to implement IDispose
on this and close the _de connection after using the instance.
And A VB Version
Public Class LDAPAuthentication
Private _de As DirectoryEntry
Private _ldapPath As String
Private _username As String
Private _domain As String
Public Sub New(ByVal ldapPath As String, ByVal domain As String, ByVal username
As String, ByVal pwd As String)
Throw New Exception("Error establishing LDAP connection: "
& ex.Message)
End Try
End Sub 'New
Public Function IsAuthenticated() As Boolean
Try
'Bind to the native AdsObject to force authentication.
Dim obj As Object = _de.NativeObject
Catch ex As Exception
Throw ex
End Try
Return True
End Function 'IsAuthenticated
Public Function getUserGroups() As String
Dim fulluser As String = _username & "@" & _domain
'setup and search for user
Dim sFilter As String = [String].Format("(&(objectClass=user)(objectCategory=person)(userPrincipalName={0}))",
fulluser)
Dim ds As New DirectorySearcher(_de, sFilter, New String() {"memberOf"})
Dim sb As New StringBuilder()
'find it
Dim sr As SearchResult = ds.FindOne()
Try
If Not (sr Is Nothing) Then
If sr.Properties.Contains("memberOf") Then
Dim o As Object
For Each o In sr.Properties("memberOf")
sb.Append(o.ToString().Split(New Char() {","c})(0).Split(New
Char() {"="c})(1))'grab the group cn
sb.Append(Chr(124))
Next o
' strip off final "|" at end of sb
Dim last As Int32 = sb.Length - 1
If last > 0 Then
sb.Remove(last, 1)
End If
End If
Else
Throw New Exception("User not found while searching groups")
End If
Catch ex As Exception
Throw New Exception("Error retrieving group information. " + ex.Message,
ex)
End Try
Return sb.ToString()
End Function 'GetGroups
End Class
HTH let us know
Regards,
Carlos Magalhaes
<Some code has been uses from other sites>
-------------------------------------------------------------
This email and any files transmitted are
confidential and intended solely for the
use of the individual or entity to which
they are addressed, whose privacy
should be respected. Any views or
opinions are solely those of the author
and do not necessarily represent those
of the Trencor Group, or any of its
representatives, unless specifically
stated.
Email transmission cannot be guaranteed
to be secure, error free or without virus
contamination. The sender therefore
accepts no liability for any errors or
omissions in the contents of this message,
nor for any virus infection that might result
from opening this message. Trencor is not
responsible in the event of any third party
interception of this email.
If you have received this email in error please notify
postmaster@... For more information about
Trencor, visit www.trencor.net <http://www.trencor.net>
I am having an issue retrieving all property values for LDAP object
entries in a SecureWay v3.2.1 DB2 instance. . . using asp.net. . .
Several of the standard attributes come back properly, like first
name, last name, email, etc. . . though the "custom" properties that
I attempt to retrieve generate the following error:
"System.NotImplementedException: Handling of this ADSVALUE type is
not yet implemented (type = 0xb)."
I have attached the code I am using to pull the data out of the
instance. If someone could point me in the right direction as to
where I would need to go to find out how to successfully retrieve
these "notimplemented" values it would be greatly appreciated.
thanks
myLDAPPath = "LDAP://" & _tierName & "/ou=" & _objectName
& ",o=avnetinc"
Dim mySearchRoot As New DirectoryEntry(myLDAPPath)
Dim myDirectorySearcher As New DirectorySearcher(mySearchRoot)
myDirectorysearcher.Filter = "(cn=" & _cn & ")"
Dim mySearchResult As SearchResult = myDirectorySearcher.FindOne()
If Not (mySearchResult Is Nothing) Then
Dim myDirectoryEntry As DirectoryEntry =
mySearchResult.GetDirectoryEntry()
myDirectoryEntry.AuthenticationType =
DirectoryServices.AuthenticationTypes.Secure
mydirectoryEntry.UserName = "rootloginID"
mydirectoryentry.Password = "rootLoginPassword"
Dim mySearchResultPath As String = mySearchResult.Path
response.write ("The path for the 'mySearchResult' search result
is : " & mySearchResultPath & "<BR><br>")
Dim myResultPropColl As ResultPropertyCollection
myResultPropColl = mySearchResult.Properties
response.write("<B>The properties of the 'mySearchResult'
are :</b><BR>")
Dim myKey As String
For Each myKey In myResultPropColl.PropertyNames
Dim tab1 As String = " "
response.write(myKey & " = ")
Dim myCollection As Object
Dim mycustomTypeCollection As String
For Each myCollection In myResultPropColl(myKey)
if instr(mycollection.tostring(),"NotImplementedException") < 1 then
response.write( cstr(myCollection) )
response.write("<BR>")
else
response.write(mycollection.tostring())
response.write("<b>Entry Ignored</b><BR>")
end if
Next myCollection
Next myKey
Else
response.write("The '" & myLDAPPath & "' path not found.")
End If