How to check whether is a member of a domain


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: How to check whether is a member of a domain

  1. #1
    Join Date
    Mar 2005
    Posts
    9

    How to check whether is a member of a domain

    Hello,

    I would like to check if a user is a member of a particular domain or not? How do I do that in ASP.NET.

    I am able to authenticate users to use my application, but I would also want to just check if he is a member of the domain without authenticating.

    The objective is to ensure he is a member of the domain without authenticating with his password.

    Can anyone help me in this regard?

    Cheers,

    Hobbes

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    I'm assuming your web application is set up for Anonymous (no) authentication so that would require that the user supply his/her account ID. With that information you can check to see if they are in a particular domain.

    You can use the System.DirectoryServices namespace to do this. Probably the easiest method would be to use the WinNT provider. The LDAP provider would require a bit more code.

    Code:
            Dim ADEntry As New System.DirectoryServices.DirectoryEntry("WinNT://<domain name>/<account ID>")
    
            Try
                Console.WriteLine(ADEntry.Name)
            Catch ex As Exception
                Console.WriteLine("User not found in domain")
            End Try
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  3. #3
    Join Date
    Mar 2005
    Posts
    9

    More Help regarding the Namespace in which the class is found.

    Hello,

    Thanks for the response. I am using windows authentication. My Web.config file reads as such....

    <authentication mode="Windows"/>

    Also, I am unable to find the namespace in which the class you have used is defined.

    System namespace does not have a definition for DirectoryServices.

    Do let me know of how to proceed.

    Regards,

    Hobbes.

  4. #4
    Join Date
    Dec 2003
    Posts
    2,750
    You have to add the System.DirectoryServices reference to your project. It isn't included in a project by default.
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center