I am using DirectoryServices, I abstracted it into a simple search class, this works 
on our site using Integrated Security only:

---------------------------------------------------
using System;
using System.DirectoryServices;   

namespace myComDotNet
{
        /// <summary>
        /// adServices - Built in functions for ldap lookups.
        /// author: Ryan Jameson
        /// </summary>
        public class adServices
        {
                public adServices()
                {
                }
                public static System.DirectoryServices.SearchResultCollection 
directorySearch(string criteria){
                  //Note : myCom.com is the name of my domain for testing purposes.
                  string sPath = "LDAP://dc=myCom,dc=com";;                
                  DirectoryEntry entry = new 
DirectoryEntry(sPath,null,null,System.DirectoryServices.AuthenticationTypes.Secure);   
              
                  System.DirectoryServices.DirectorySearcher mySearcher = new 
                  System.DirectoryServices.DirectorySearcher(entry);
                  mySearcher.Filter = ("("+criteria+")");
                  //A list of the properties you need
                  mySearcher.PropertiesToLoad.Add("samAccountName");
                  mySearcher.PropertiesToLoad.Add("distinguishedName");
                  mySearcher.PropertiesToLoad.Add("description");
                  mySearcher.PropertiesToLoad.Add("sn");
                  mySearcher.PropertiesToLoad.Add("givenname");
                  mySearcher.PropertiesToLoad.Add("department");                  
                  mySearcher.PropertiesToLoad.Add("telephonenumber");             
                  mySearcher.PropertiesToLoad.Add("manager");
                  mySearcher.PropertiesToLoad.Add("mail");
                  mySearcher.PropertiesToLoad.Add("name");                
                  //done list
                  System.DirectoryServices.SearchResultCollection resEnt = 
mySearcher.FindAll();
                  return resEnt;                
                  }
          }
}






<>< Ryan



-----Original Message-----
From: Sapp, Tim [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 07, 2003 10:31 AM
To: dotnet
Subject: System.DirectoryServices




Anyone work with System.DirectoryServices?

I have a web site that I wrote for creating users from an internal web site.
I wrote is using ASP and ADSI. I am re-writing it using ASP.Net and
importing the System.DirectoryServices interfaces.  When I use the following
line I connect with no problems....

   DIM DE as DirectoryEntry
   Dim DomainPath as String = "LDAP://Domain/OU=Test_Tsapp,DC=Domain,DC=PVT";
   Dim DirEntry As New DirectoryEntry(DomainPath, UserID, Password)

When I remove anonymous from the site and set it up with integrated security
it fails when I try and connect without the userID and password.

   Dim DirEntry As New DirectoryEntry(DomainPath) 

According to the MSDN I should be able to connect but I keep getting errors.
There are no errors on the connection, just when I try and list the contents
of the OU.

   For Each DE In DirEntry.Children
      temp.Text = temp.Text & DE.Name
   Next



Anyone work with DS enough to give me some pointers?



Tim Sapp






---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to %%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/



---
You are currently subscribed to dotnet as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/


Reply via email to