Hi,
I have a list of users and i need to check if they exist in a specific group of LDAP Domain or not. it's not like authentiicating user but needs to check their existence without password.
I want to check the network login users with LDAP specific group for one of my Vb.Net windows application page. it's not a regular authentication with UserName and Password. check if the specific user is active in LDAP group or not by passing only Network Username.
can any one have similar kind of stuff, reply me same. it's urgent.
Awaiting for reply.
Regards,
Venky
Jaganathan BantheswaranPosted Jul 20, 2011, 2:39 AM
This is in C#,
string userName = "TargetUserName";
using (DirectorySearcher searcher = new DirectorySearcher("GC://yourdomain.com"))
{
searcher.Filter = string.Format("(&(objectClass=user)(sAMAccountName={0}))", userName);
using (SearchResultCollection results = searcher.FindAll())
{
if (results.Count > 0)
Debug.WriteLine("Found User");
}
}
If you want to target only a single domain use "LDAP://mydomain.com" instead of "GC://mydomain.com". You can also supply searcher.SearchRoot with a DirectoryEntry to use as the root of a search (i.e. a specific OU or domain).
venkii RPosted Jul 20, 2011, 3:43 AM
Thanks for ur reply with good stuff of code which will useful for me. my application is in vb.net. i will change it from C# to vb. no problem.
Hope it may work in vb for me also.
Thanks again.