|
-
May 27th, 2008, 08:27 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Active Directory
Hi, is it possible to connect to the Active Directory without using a login and password?
Thanks
-
May 27th, 2008, 08:52 AM
#2
Re: Active Directory
seems you are working on app related to Active directory,may be you can look into this sample application.
http://www.codeproject.com/KB/system...edirquery.aspx
Last edited by riteshjain1982; May 27th, 2008 at 08:59 AM.
__________________
Rate the posts that helped you 
-
May 27th, 2008, 09:10 AM
#3
Thread Starter
Addicted Member
Re: Active Directory
I need to know, for a specific user, in which group he's in.
-
May 27th, 2008, 09:23 AM
#4
Re: Active Directory
have you tried with PropertiesToLoad.Add("memberOf") property of DirectorySearcher object
__________________
Rate the posts that helped you 
-
May 27th, 2008, 09:38 AM
#5
Thread Starter
Addicted Member
Re: Active Directory
How do I get the IP of the LDAP?
-
May 27th, 2008, 10:30 AM
#6
Re: Active Directory
I found one sample,this will work if user and machine on which you are running you app is in same domain.
Code:
Public Sub GetUserGroups(ByVal UserName As String)
Dim search As New DirectorySearcher("")
Dim intG_Counter As Int
Dim intcounter As Int
Dim strGroupName As String
Dim strPrimaryGroup As String
Dim GroupArr As Array
Dim DataToWriteGroups As String
Try
search.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))(objectCategory=user)(samaccountname=" + UserName.ToString.Trim + "))"
search.PropertiesToLoad.Add("memberOf")
Dim result As SearchResult = search.FindOne()
If Not (IsNothing(result)) Then
Try
intG_Counter = result.Properties("memberOf").Count
Catch exc As NullReferenceException
intG_Counter = 0
End Try
If intG_Counter > 0 Then
DataToWriteGroups = "Group(s) Belongs To User - " + UserName + ""
For intcounter = 0 To intG_Counter - 1
strGroupName = ""
strGroupName = CStr(result.Properties("memberOf")(intcounter))
GroupArr = Split(strGroupName, ",")
If Not (IsNothing(GroupArr(0))) Then
strGroupName = Mid(GroupArr(0), 4, Len(GroupArr(0)) - 3)
MessageBox.Show("Group(s) belongs to " + UserName + " - " & strGroupName )
End If
Next
End If
'' Get primary Group
strPrimaryGroup = GetPrimaryGroupName(UserName)
If strPrimaryGroup.Length > 0 Then
MessageBox.Show("Primary Group belongs to " + UserName + " - " & strPrimaryGroup )
End If
End If
Catch exc As Exception
MessageBox.Show(ex.Message, " Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
Finally
search.Dispose()
End Try
End Sub
Just pass the user name.
__________________
Rate the posts that helped you 
-
May 27th, 2008, 11:45 AM
#7
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|