ChangePassword with ADAM

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi All,

We are trying to use Active Directory Application Mode (ADAM) for one of our
Directory based application. We are able to authenticate using user created
in ADAM as user object. But somehow change password method is not working
for the user. Following is the code to change user's password :

static void Main()
{
const int ADS_OPTION_PASSWORD_PORTNUMBER = 6;
const int ADS_OPTION_PASSWORD_METHOD = 7;
const int ADS_PASSWORD_ENCODE_CLEAR = 1;

AuthenticationTypes AuthTypes; // Authentication flags.
int intPort; // Port for instance.
DirectoryEntry objDE; // User object.
DirectoryEntry objResultEntry;
Object obj;

string strPath; // Binding path.
string strPort; // Port for instance.
string strServer; // DNS name of the computer with
// the ADAM installation.
string strUser; // User DN.

// Construct the binding string.
strServer = "gate";
strPort = "389";
strUser = "CN=IMARKET";


strPath = String.Concat("LDAP://";, strServer, ":", strPort, "/",
strUser);
Console.WriteLine("Bind to: {0}", strPath);

strUser = "CN=amit,CN=IMARKET";

AuthTypes = AuthenticationTypes.None;

// Bind to user object using LDAP port.
try
{
objDE = new DirectoryEntry();
objDE.Path = strPath;
objDE.Username = strUser;
objDE.Password = "amit";
objDE.AuthenticationType = AuthTypes;
obj = objDE.NativeObject;

}
catch (Exception e)
{
Console.WriteLine("Error: Bind failed.");
Console.WriteLine(" {0}.", e.Message);
Console.ReadLine();
return;
}
intPort = Int32.Parse(strPort);
try
{


objDE.Invoke("SetOption", new object[]{ADS_OPTION_PASSWORD_PORTNUMBER,
intPort});
objDE.Invoke("SetOption", new
object[]{ADS_OPTION_PASSWORD_METHOD,ADS_PASSWORD_ENCODE_CLEAR});
DirectorySearcher objSearch = new DirectorySearcher(objDE,
"(&(objectClass=user)(name=amit))");
objSearch.SearchScope = SearchScope.Subtree;
SearchResult objResult = objSearch.FindOne();

objResultEntry = objResult.GetDirectoryEntry();
Console.WriteLine(objResultEntry.Properties["memberOf"].Value);

// With these options also, result is same.
//objResultEntry.Invoke("SetOption", new
object[]{ADS_OPTION_PASSWORD_PORTNUMBER, 636});
//objResultEntry.Invoke("SetOption", new
object[]{ADS_OPTION_PASSWORD_METHOD,ADS_PASSWORD_ENCODE_CLEAR});

objResultEntry.Invoke("ChangePassword", new object[]{"amit", "amit12"});

}
catch (Exception e)
{
Console.WriteLine(" {0}.", e.Message);
Console.ReadLine();
return;
}

Console.WriteLine("Success: Password set.");
Console.ReadLine();
return;
}

Every thing goes fine. But when we try to invoke ChangePassword method, it
throws an exception saying : {"The directory property cannot be found in the
cache.\r\n"}.

Regards,
Amit


.



Relevant Pages

  • Re: Security Logging in ADAM
    ... How does an anonymous login authenticate anyone? ... If a bind was performed against ADAM, there should be a matching audit event ... in the security event log on the ADAM machine assuming that logon events are ...
    (microsoft.public.windows.server.active_directory)
  • Re: ADAM Authentication
    ... The client app in question is the Windows Address Book. ... Joe Kaplan wrote: ... The ADAM ADSI editor ... then ADAM would be able to authenticate users from HOME. ...
    (microsoft.public.windows.server.active_directory)
  • Re: ADAM Authentication
    ... The ADAM ADSI editor ... then ADAM would be able to authenticate users from HOME. ... if I attempt to bind to the ADAM instance using that same ... Lets say my domain username is CAMPUS/aaron. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Security Logging in ADAM
    ... How does an anonymous login authenticate anyone? ... If a bind was performed against ADAM, there should be a matching audit event ... in the security event log on the ADAM machine assuming that logon events are ... security events, and when I log in as that user using ADSI edit, I get ...
    (microsoft.public.windows.server.active_directory)
  • Re: ADAM Authentication
    ... But I'm not trying to authenticate as HOME\joebob. ... The ADAM ADSI editor ... Lets say my domain username is CAMPUS/aaron. ...
    (microsoft.public.windows.server.active_directory)