473,386 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Enumerate members of a group in vb.net codebehind pages...

Hello!

I need to get a list of all members of a specific group (whether or not the currently logged-in user is a member of that group) in a VB.NET codebehind page.

I am able to get all the information on the currently logged-in user (full name, phone number, e-mail address, etc.), but I cannot get my head around the filters needed to get membership in a group.

Here is what I have so far:

Public Function GetSalesGroup()
Dim search As DirectorySearcher = New DirectorySearcher(_path)
search.Filter = "(cn=Sales)"
search.PropertiesToLoad.Add("group")
Dim groupNames As StringBuilder = New StringBuilder

Try
Dim result As SearchResult = search.FindOne()
Dim propertyCount As Integer = result.Properties("memberOf").Count

Dim dn As String
Dim equalsIndex, commaIndex

Dim propertyCounter As Integer

For propertyCounter = 0 To propertyCount - 1
dn = CType(result.Properties("memberOf")(propertyCounte r), String)

equalsIndex = dn.IndexOf("=", 1)
commaIndex = dn.IndexOf(",", 1)
If (equalsIndex = -1) Then
Return Nothing
End If

groupNames.Append(dn.Substring((equalsIndex + 1), (commaIndex - equalsIndex) - 1))
groupNames.Append("|")
Next

Catch ex As Exception
Throw New Exception("Error obtaining Sales group membership. " & ex.Message & "<br>")
End Try

Return groupNames.ToString()
End Function

The results of this are supposed to be thrown to a session variable upon return.

Help!

Thanks!

SteveO

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
2 1478
....bounce...

Anyone?

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #2
> Anyone?

I'm anyone!

BTW, that's "bump," and it really helps to repeat the question for those of
us that hide read messages in our newsgroup client.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Steve Oswald via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:55******************************@DotNetMonste r.com...
...bounce...

Anyone?

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #3

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

Similar topics

6
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
3
by: shiv | last post by:
Hi all, I am able to read groups in the domain but not able to read the members within each group. can somebody help? here goes the code DirectoryEntry m_obDirEntry=new DirectoryEntry...
3
by: nevets2001uk | last post by:
Hi. I've just started my second ASP.NET (VB) app and I'm using codebehind this time. I'm not using visual studio but am instead coding it all in notepad (HTML, ASP.NET and CSS) I'm trying to...
6
by: Plamen Doykov | last post by:
Hi all I have converted a simple project from ASP.NET 1 to 2.0 with the latest prerelease of Visual Studio 2005. The problem is I can't access internal members from the code behind. It gives:...
23
by: BH Jodo Kast | last post by:
Hi, I found this handy script and I'm trying to convert it to VB.NET. It pops up a list of members in the Administrators/Builtin group. Can't seem to get DirectorySearcher or DirectoryEntry...
1
by: ginolard | last post by:
I'm trying to find out how to enumerate all local groups on a machine and list their membership. It's easy in Vbscript but it seems to be considerably more tricky in VB.NET. Am I missing...
6
by: antonyliu2002 | last post by:
Right now I put my VB code in the aspx pages. I would prefer to use codebehind, especially many of my VB functions may be shared across multiple aspx pages. I've tried a few pages with...
0
by: bcanter | last post by:
I found a file on the web that will allow you to enumerate groups but it was an .hta and the top level admins won't allow this. I need to give managers access to the groups so that when a new user is...
2
by: =?Utf-8?B?am1hZ2FyYW0=?= | last post by:
I'm trying to get a list of user accounts on the local computer - the same list you see when you are about to log in to Windows XP or Vista. This needs to work on a home computer (not connected to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.