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.