Hi All
I'm trying to create a scheduled job to import users from Active directory that don't already exist in the DNN database.
The code that i'm using to access the Active Directory works fine in a module, but once it gets added into a class library and the dll gets called from the Scheduler I get the following message.
"The specified domain either does not exist or could not be contacted. at System.DirectoryServices.DirectoryEntry.Bind"
I don't get this error when I run the same code in a module contained on a page. The method that it is failing on is the actual creation of the DirectoryEntry object.
private DirectoryEntry GetDirectoryObject(string sDN)
{
string sSearchStr = sDN;
System.DirectoryServices.DirectoryEntry entry =
new System.DirectoryServices.DirectoryEntry(sSearchStr, "{domain}\\{username}", "{password}", AuthenticationTypes.Secure);
return entry;
}
I thought this initially was down to the scheduler running under a different user account, which is why I've started to use the username and password properties of the DirectoryServices object, but this has not resolved the problem.
Does anyone have any suggestions? The Path that I used in the Module to access the AD should remain unchanged shouldn't it? I didn't think that I would have to change the path to the domain controller just because I was passing in the username and password now.
Any help is appreciated
Thanks
Martin.