472,779 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Create and authenticate user in AD

The following code is working fine, i can create the user in the Active
Directory and "enable" it.
My problem is that, when i'm trying to authenticate him, i can't get to
work!! The user and pass is correct, but it can't authenticate. If i try
other user created in the AD, it work just fine!!!

< Create User>

// Bind to the Users container, add a new user. Connecting with admin
DirectoryEntry de = new
de = de.Children.Find("CN=Users");

//Create the user
DirectoryEntry newUser = de.Children.Add("CN=" + txtLogin.Text, "user");

//Add the password
newUser.Password = txtPassword.Text;
.....(Search the user)...

//Bind User to AD to enable account
ActiveDs.IADsUser thisNewADSIuser = (ActiveDs.IADsUser)
thisNewADSIuser.AccountDisabled = false;

< Authenticate User>
//Connecting with user and password created in the "Create User" code...
DirectoryEntry entry = new
//Bind to the native AdsObject to force authentication.
object obj = entry.NativeObject;

DirectorySearcher search = new DirectorySearcher(entry);

search.Filter = "(cn=" + username + ")";
SearchResult result = search.FindOne();

if(result == null)
return false;
catch (Exception ex)
{ return false; }

return true;

<--End Code-->

What i missed!? I try to search in the msdn (microsoft), but no luck!!
Nothing :(


Jul 21 '05 #1
0 1487

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

Similar topics

by: Jason Shohet | last post by:
A user runs a .NET application that authenticates them against active directory (they're coming in over VPN so they don't log on to the network normally). Once they log in, I want to take their...
by: Renato Neves | last post by:
The following code is working fine, i can create the user in the Active Directory and "enable" it. My problem is that, when i'm trying to authenticate him, i can't get to work!! The user and pass...
by: ALI-R | last post by:
I know how to authenticate to a webservice using either of these ways(Assuming that rService represents the webservice): 1) rService.Credentials = new...
by: EricRybarczyk | last post by:
I am starting a rewrite of an existing Classic ASP web site in ASP.NET 2.0. The existing ASP application has several types of users, each with a separate login process (separate login page,...
by: kevin.vaughan | last post by:
Hello Everyone, Is it possible to authenticate the windows password through Active Directory? If so, how would this be done. I have a login screen in my application and am trying to set it up...
by: fomalhaut | last post by:
Hi All, I'm builing an application that requires domain admin access to run, and I'm trying to allow for the application to be run as a normal user and allow the user to provide it with a...
by: Michael Howes | last post by:
I would think this would be very, very easy but in the 50 searches I've done I haven't found anything. If our application requires login and that user/password be a local windows account or more...
by: kang jia | last post by:
hi i am currently learning Django framework and i have to do a login page at the moment. i have used the code like following: from django.contrib.auth import authenticate, login def...
by: Jon | last post by:
I am modifying an app for a customer in ASP.Net 1.1. The app is running on a server outside their network, yet they want to authenticate users against their internal active directory set up (they...
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.