Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2004, 01:36 AM
Authorized User
 
Join Date: Apr 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sara_1981
Default web application, get group name - active directory

I want to access to a special group in active directory but with this function I could just that a special user is exist in active directory or not, I mean I want to see that a user is exist in special group which I myself specified. could anyone help me and change this code to which could do what I want.
thanks
    Public Function ValidateUser(ByVal Domain As String, ByVal username As String, ByVal password As String) As Boolean
        Dim dehelp As String
        dehelp = "LDAP://"
        Try
            Dim de As New DirectoryEntry(dehelp & Domain, username, password, AuthenticationTypes.Secure)

            Dim srch As New DirectorySearcher(de)



            'srch.Filter = "(objectClass=Group)"
            srch.Filter = "(&(objectClass=user)(samAccountName=" & username & "))"
            Dim result As SearchResult = srch.FindOne
            'Dim obj As DirectoryEntry
            If Not result Is Nothing Then
                'obj = result.GetDirectoryEntry()
                'Response.Write(obj)

                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            Console.Write(ex.Message + ControlChars.NewLine + ex.StackTrace)
            Return False
        End Try
    End Function

Regards
Sara
__________________
Regards
Sara





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add user to group - Active Directory anurag_ur ASP.NET 2.0 Professional 0 January 17th, 2006 02:54 AM
Add user to group - Active Directory anurag_ur ASP.NET 1.0 and 1.1 Professional 0 January 16th, 2006 09:25 AM
Add User to group - Active Directory anurag_ur .NET Framework 1.x 0 January 16th, 2006 09:15 AM
Add User to group - Active Directory anurag_ur C# 0 January 16th, 2006 09:13 AM
Add User to group - Active Directory anurag_ur ASP.NET 1.0 and 1.1 Basics 0 January 16th, 2006 09:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.