find user in AD failed

  • Thread starter Thread starter Johnny Hu
  • Start date Start date
J

Johnny Hu

i download some ADHelper class from csharpcorner and codepeoject
but i found some users can be found and some cannot

i checked the code, they all use directorySearch,
i cannot figure out anything wrong

anyone has encounter this?
is there other ways to validate AD users ? i am working on a logon module.
 
Hi Johnny,

I think you may try the demo below to see if you can find the AD objects
with the demo sample.
Simple Active Directory Browser
http://www.codeproject.com/csharp/ActiveDirectoryBrowser1.asp?target=enumera
te%7Clistview

As for the Validate user, we can use the LogonUser API, here are two KB
about it.

HOWTO: Validate User Credentials on Microsoft Operating Systems (180548)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;180548

How to validate Windows user rights in a Visual Basic .NET application
(841699)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;841699


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
i think LogonUser API should work
i'll try tomorrow

is there other API i can use to change password ?
 
Hi Johnny,

To change a password, we can use the IADsUser::ChangePassword or
NetUserChangePassword API.

How To Change Passwords Programmatically in Windows NT, Windows 2000, or
Windows XP (151546)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;151546

When using the IADsUser::ChangePassword or IADsUser::SetPassword methods
from DirectoryEntry::Inoke, it is not necessary to call the
DirectoryEntry::CommitChanges method to force the local cache to server.
The password change methods do this work for you.

The following code illustrates how to Invoke ChangePassword from C#.Net.


using System;
using System.DirectoryServices;

namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
try
{
DirectoryEntry de = new
DirectoryEntry("LDAP://cn=Holly,Ou=Red
Dwarf,dc=br549,dc=nttest,dc=microsoft,dc=com", "br549\\Fordp", "fordp10+",
AuthenticationTypes.Secure);
String strPwdOld ;
String strPwdNew ;
strPwdOld = "holly11";
strPwdNew = "holly10";
de.Invoke( "ChangePassword", new
Object[]{strPwdOld, strPwdNew});
Console.WriteLine(de.Name);
}
catch( System.Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
i download some ADHelper class from csharpcorner and codepeoject
but i found some users can be found and some cannot
i checked the code, they all use directorySearch,
i cannot figure out anything wrong

Well, show us your code, and tell us what you want to do - hard to say
what's wrong from just these lines........

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Back
Top