473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ADAM user SetOption, SetPassword having exception HRESULT: 0x80005008

I have problem setting the password for an ADAM user using C#. I used
the SetPassword code given in the Microsoft page, changed several
parameters, but ran into an exception. I wonder if other people have
solved this problem. But I have searched Google groups for a couple
days but still couldn't get a solution.

I copied the code from:

http://msdn.microsoft.com/library/de...r_password.asp

Then when the program reaches the first call of:

objUser.Invoke("SetOption", ...);

It throws the an exception with the following information:

Message:
Exception has been thrown by the target of an invocation.

BaseException:
Exception from HRESULT: 0x80005008.

Inner Exception:
System.Runtime.InteropServices.COMException (0x80005008):
Exception from HRESULT: 0x80005008.

Source:
mscorlib

StackTrace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.DirectoryServices.DirectoryEntry.Invoke(Str ing
methodName, Object[] args)
at WindowsApplication1.Form1.button1_Click(Object sender, EventArgs
e) in c:\setpassword\windowsapplication1\form1.cs:line 153
System.Object InvokeDispMethod(System.String,
System.Reflection.BindingFlags,

TargetSite:
System.Object, System.Object[], Boolean[], Int32, System.String[])

For your information, here is the code I have:

<-- code begins -->

private void button1_Click(object sender, System.EventArgs e)
{
const long ADS_OPTION_PASSWORD_PORTNUMBER = 6;
const long ADS_OPTION_PASSWORD_METHOD = 7;
const int ADS_PASSWORD_ENCODE_REQUIRE_SSL = 0;
const int ADS_PASSWORD_ENCODE_CLEAR = 1;

AuthenticationTypes AuthTypes; // Authentication flags.
int intPort; // Port for instance.
DirectoryEntry objUser; // User object.
string strPath; // Binding path.
string strPort; // Port for instance.
string strServer; // Server for instance.
string strUser; // User DN.

// Construct ADsPath binding string.
// Change "localhost" to appropriate server.
// Change "389" to LDAP port appropriate for instance,
// or use SSL port (default = "636") for secure connection.
// Change "CN=TestUser,O=Fabrikam,C=US" to DN of user.
strServer = "[MY_LDAP_SERVER]";
strPort = "389";
strUser = "[A_USER_DISTINGUISHED_NAME]";
strPath = String.Concat("LDAP://", strServer,
":", strPort, "/", strUser);
Debug.WriteLine("Bind to: " + strPath);

// Set authentication flags.
// For non-secure connection, use LDAP port and
// ADS_USE_SIGNING |
// ADS_USE_SEALING |
// ADS_SECURE_AUTHENTICATION
// For secure connection, use SSL port and
// ADS_USE_SSL | ADS_SECURE_AUTHENTICATION
AuthTypes = AuthenticationTypes.Signing |
AuthenticationTypes.Sealing |
AuthenticationTypes.Secure;

// Bind to user object using LDAP port.
try
{
objUser = new DirectoryEntry(
strPath, "[LDAP_USER_NAME]", "[LDAP_USER_PASSWORD", AuthTypes);
objUser.RefreshCache();
}
catch (Exception e)
{
Debug.WriteLine("Error: Bind failed.");
Debug.WriteLine(" " + e.Message);
return;
}

// Set port number, method, and password.
intPort = Int32.Parse(strPort);
try
{
// Note: A password should normally
// not be entered in code,
// but should be obtained from the user interface.

objUser.Invoke("SetOption", new object[]
{ADS_OPTION_PASSWORD_PORTNUMBER, intPort}); <-- **Exception thrown
here**

objUser.Invoke("SetOption", new object[]
{ADS_OPTION_PASSWORD_METHOD,
ADS_PASSWORD_ENCODE_CLEAR});

objUser.Invoke("SetPassword", new object[]
{"goodpassword"});

}
catch (Exception e)
{
Debug.WriteLine("Error: Set password failed.");
Debug.Indent();
Debug.WriteLine(e.Message);
Debug.WriteLine("base exception\n" + e.GetBaseException().Message);
Debug.WriteLine("inner exception\n" + e.InnerException);
Debug.WriteLine("source\n" + e.Source);
Debug.WriteLine("StackTrace\n" + e.StackTrace);
Debug.WriteLine("TargetSite\n" + e.TargetSite);
return;
}

Debug.WriteLine("Success: Password set.");
return;

}

<-- code ends -->

Thank you very much and I appreciate anyone who has any suggestions!
Nov 15 '05 #1
3 7818
Problem solved!
I have to phone up Microsoft to get them e-mail me a Hotfix.

cool.

le****@mail.com (Lekyan) wrote in message news:<cb*************************@posting.google.c om>...
I have problem setting the password for an ADAM user using C#. I used
the SetPassword code given in the Microsoft page, changed several
parameters, but ran into an exception. I wonder if other people have
solved this problem. But I have searched Google groups for a couple
days but still couldn't get a solution.

I copied the code from:

http://msdn.microsoft.com/library/de...r_password.asp

Then when the program reaches the first call of:

objUser.Invoke("SetOption", ...);

It throws the an exception with the following information:

Message:
Exception has been thrown by the target of an invocation.

BaseException:
Exception from HRESULT: 0x80005008.

Inner Exception:
System.Runtime.InteropServices.COMException (0x80005008):
Exception from HRESULT: 0x80005008.

Source:
mscorlib

StackTrace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args)
at System.DirectoryServices.DirectoryEntry.Invoke(Str ing
methodName, Object[] args)
at WindowsApplication1.Form1.button1_Click(Object sender, EventArgs
e) in c:\setpassword\windowsapplication1\form1.cs:line 153
System.Object InvokeDispMethod(System.String,
System.Reflection.BindingFlags,

TargetSite:
System.Object, System.Object[], Boolean[], Int32, System.String[])

For your information, here is the code I have:

<-- code begins -->

private void button1_Click(object sender, System.EventArgs e)
{
const long ADS_OPTION_PASSWORD_PORTNUMBER = 6;
const long ADS_OPTION_PASSWORD_METHOD = 7;
const int ADS_PASSWORD_ENCODE_REQUIRE_SSL = 0;
const int ADS_PASSWORD_ENCODE_CLEAR = 1;

AuthenticationTypes AuthTypes; // Authentication flags.
int intPort; // Port for instance.
DirectoryEntry objUser; // User object.
string strPath; // Binding path.
string strPort; // Port for instance.
string strServer; // Server for instance.
string strUser; // User DN.

// Construct ADsPath binding string.
// Change "localhost" to appropriate server.
// Change "389" to LDAP port appropriate for instance,
// or use SSL port (default = "636") for secure connection.
// Change "CN=TestUser,O=Fabrikam,C=US" to DN of user.
strServer = "[MY_LDAP_SERVER]";
strPort = "389";
strUser = "[A_USER_DISTINGUISHED_NAME]";
strPath = String.Concat("LDAP://", strServer,
":", strPort, "/", strUser);
Debug.WriteLine("Bind to: " + strPath);

// Set authentication flags.
// For non-secure connection, use LDAP port and
// ADS_USE_SIGNING |
// ADS_USE_SEALING |
// ADS_SECURE_AUTHENTICATION
// For secure connection, use SSL port and
// ADS_USE_SSL | ADS_SECURE_AUTHENTICATION
AuthTypes = AuthenticationTypes.Signing |
AuthenticationTypes.Sealing |
AuthenticationTypes.Secure;

// Bind to user object using LDAP port.
try
{
objUser = new DirectoryEntry(
strPath, "[LDAP_USER_NAME]", "[LDAP_USER_PASSWORD", AuthTypes);
objUser.RefreshCache();
}
catch (Exception e)
{
Debug.WriteLine("Error: Bind failed.");
Debug.WriteLine(" " + e.Message);
return;
}

// Set port number, method, and password.
intPort = Int32.Parse(strPort);
try
{
// Note: A password should normally
// not be entered in code,
// but should be obtained from the user interface.

objUser.Invoke("SetOption", new object[]
{ADS_OPTION_PASSWORD_PORTNUMBER, intPort}); <-- **Exception thrown
here**

objUser.Invoke("SetOption", new object[]
{ADS_OPTION_PASSWORD_METHOD,
ADS_PASSWORD_ENCODE_CLEAR});

objUser.Invoke("SetPassword", new object[]
{"goodpassword"});

}
catch (Exception e)
{
Debug.WriteLine("Error: Set password failed.");
Debug.Indent();
Debug.WriteLine(e.Message);
Debug.WriteLine("base exception\n" + e.GetBaseException().Message);
Debug.WriteLine("inner exception\n" + e.InnerException);
Debug.WriteLine("source\n" + e.Source);
Debug.WriteLine("StackTrace\n" + e.StackTrace);
Debug.WriteLine("TargetSite\n" + e.TargetSite);
return;
}

Debug.WriteLine("Success: Password set.");
return;

}

<-- code ends -->

Thank you very much and I appreciate anyone who has any suggestions!

Nov 15 '05 #2
So what was the hotfix that microsoft sent you? I'm trying to perform the same function and am getting the same issue from my web server that is attached to the domain. I run the code locally and I don't have any issues, but when it hits the first SetOption is errors. If you have the name of the hotfix or who you talked to at Microsoft I would appreciate it.

Thanks,
m blackstone

From http://www.developmentnow.com/g/36_2...0x80005008.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Mar 3 '06 #3
Really great, you also post the answer....

From http://www.developmentnow.com/g/36_2...0x80005008.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Oct 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: idiot | last post by:
public DirectoryEntry Find(string, string) method get Exception from HRESULT: 0x80005008 public DirectoryEntry Find(string); method get NullReferenceException source code : string strSchema =...
0
by: BizWorld | last post by:
I am using a com component in my web application. when i call a method of com component. it gives the following error only ComException HRESULT: 0xC0000005 If i run this com component in VB 6...
0
by: Pedro CLIKEAR | last post by:
The problem happens when we try to set the password for two different users with DirectoryEntry.Invoke method. The first time we use user.Invoke("SetPassword",new object {pwdUsuario}); it works...
2
by: Jessica | last post by:
When I create a single LDAP ActiveDirectory user and use DirectoryEntry.Invoke("SetPassword"...), the user is created and the password is set with no problems. However, when I try to add more...
2
by: sgr | last post by:
Hello I'm making an application that uses an excel worksheet, My problem appears when I open the worksheet to see the data (then I close it and save the changes) and I try to insert a new row from...
3
by: Terry Olsen | last post by:
I'm trying to add a domain user to a local group using the code below: Dim LCL As New DirectoryEntry("WinNT://" + Environment.MachineName + ",computer") Dim DOM As New...
3
by: roundcrisis | last post by:
That is the whole question I have a lsit of DSN availables and to use these for an ODBC connection I would mostly need to prompt for username and password, how can i do this? Thanks
0
by: shinevpaul | last post by:
I am trying to create user account in ADAM using ASP .Net 2.0 / C#. but giving an exception on "setpassword" property. The code is as follows: : user.Invoke("SetPassword", new object {...
0
by: shrikant kesh | last post by:
Hi All, We are able to create new user successfully on the active directory but the SetPassword method is taking around 1.5 minutes to complete the process. Below is the code of the snippet of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.