How to authenticate usera who are dispersed across OU's inside AD RRS feed

  • Question

  • User-1648726239 posted

    I have a requirement where the users of my application will be authenticated against AD, but the user being dispersed across OU's inside Active Directory.

    Assuming that all the users are present  inside CN= USER can be authenticated using the below code and it worked for me 

    string domainAndUsername = domain + @"\" + username;
    DirectoryEntry entry = new DirectoryEntry("LDAP://server/CN=Users;DC=mydomain;DC=in");
    entry.Username = domainAndUsername;
    entry.Password = pwd;
    entry.AuthenticationType = AuthenticationTypes.Secure;
        //Bind to the native AdsObject to force authentication.
        Object obj = entry.NativeObject;
        DirectorySearcher search = new DirectorySearcher(entry);
        search.Filter = "(SAMAccountName=" + username + ")";
        SearchResult result = search.FindOne();
        if (null == result)
            return false;
        _path = result.Path;
        _filterAttribute = (String)result.Properties["cn"][0];
    catch (Exception ex)
        throw new Exception("Error authenticating user. " + ex.Message);

    AS my application users are dispersed across AD and are found inside OU's within AD. i need a solution where i pull out all the
    USERS inside the AD and authenticate against their credentials.

    IDE : Visual Studio 2005 

    Thanks In Advance
    Friday, February 26, 2010 1:14 AM

All replies

  • User-1648726239 posted

    AS my application users are dispersed across AD and are found inside OU's within AD. i need a solution where i pull out all the

    USERS inside the AD and authenticate against their credentials. 

    Thanks In Advance

    Pruthvi Sagar

    Friday, February 26, 2010 4:19 AM