Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / September 2007



Tip: Looking for answers? Try searching our database.

.NET Active Directory Interation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fshin - 13 Aug 2007 21:31 GMT
Any ideas what's up with this code?  Of note, I'm pretty clueless about active
directory and .net!

<cfscript>
    de = createObject("dotnet",    
             "System.DirectoryServices.DirectoryEntry",        
             
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.directoryservices.dll");
    de.set_Path("LDAP://something/CN=Users,DC=something,DC=something");
    de.set_Username("domain\username");
    de.set_Password("password");
   
    deSearch = createObject("dotnet",
"System.DirectoryServices.DirectorySearcher",  
             
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.directoryservices.dll");   
    deSearch.set_SearchRoot(de);
    deSearch.set_Filter('(&(objectCategory=user)(cn=" + testUser + "))');
   
    results = createObject("dotnet", "System.DirectoryServices.SearchResult",  
             
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.directoryservices.dll");
    results = deSearch.FindOne();
</cfscript>
GArlington - 14 Aug 2007 10:16 GMT
> Any ideas what's up with this code?  Of note, I'm pretty clueless about active
> directory and .net!
[quoted text clipped - 20 lines]
>         results = deSearch.FindOne();
>  </cfscript>

I believe you are looking for <cfldap> (see CF docs)
Michael - 06 Sep 2007 01:57 GMT
What exactly is the problem?

There are a couple of things that may not be right.

1. You need to set the userPrincipalName attribute.  At the same time, set the
sAMAccountName attribute.  userPrincipalName is generally the email address.  
user@domain.com.  sAMAccountName is just the username part of the email address.

2. You need to call the de.setInfo() method after setting the
userPrincipalName, but BEFORE setting the password.  This actually creates the
directory object.  You can't set a password on an object that doesn't yet exist
in the directory.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.