|
Hello,
I'm trying to get the group in which a user is sitting. I searched and found an artikle here. Converted it from c# to VB.NET.
This is the code:
Private Function GetADUserGroups(ByVal userName As String) As String
Dim search As sys.DirectorySearcher = New sys.DirectorySearcher
search.Filter = String.Format("(cn=*)", userName)
search.PropertiesToLoad.Add("memberOf")
Dim groupsList As System.Text.StringBuilder = New System.Text.StringBuilder
groupsList.Append("test")
result = search.FindOne()
If Not result Is Nothing Then
Dim groupCount As Integer
groupCount = result.Properties.Count
MessageBox.Show(groupCount)
Dim counter As Integer
For counter = 0 To groupCount - 1 Step counter + 1
groupsList.Append(CType(result.Properties("memberOf").Item(counter), String)) groupsList.Append("|")
Next
End If
groupsList.Length -= 1 'remove the last "|" symbol
Return groupsList.ToString()
End Function
if i try to run it i get a System.NullReferenceException in the for loop.
does anyone know what the problem is?
any other ideas are welcome.
thanks in advance
Bis
|
|
|
|
|
Hi,
I would like to give some suggestions so that i will work for you, as i have changed the same in my testing environment and it is working . . .
Include the following line as the first line inside the function
Dim entry As New DirectoryEntry("LDAP://<domainname.com>")
Change the second line as follows
Dim search As DirectorySearcher = New DirectorySearcher(entry)
include a if condition inside the for loop and it should appear like this
<br />
For counter = 0 To groupCount - 1 Step counter + 1<br />
If result.Properties.Contains("memberOf") Then<br />
groupsList.Append(CType(result.Properties("memberOf").Item(counter), String)) <br />
groupsList.Append("|")<br />
End If <br />
<br />
Next<br />
<br />
i hope you would have declared result as search result<br />
<br />
Hope this will
|
|
|
|
|
Thanks for the reply, but still have some problems
Made the changes you told me, but still doesn't work. Maybe it's the given username. I just give eg John. Is this correct or do you need to specify your domain as well?
Bis
|
|
|
|
|
Hi,
Try giving the domain name with the com extension. then you will get it
Sasidar
|
|
|
|
|
After some tests, i noticed that the code in the If condition never gets executed. So in other words, the property memberOf is not available.
What can i do to get it available?
Thanks in advance
Kris
|
|
|
|
|
Kris,
Can you post your code here so that let us have a look ?
Sasidar
|
|
|
|
|
Hello,
I've got a form that I create to show certain information about a specfied ClientID. I also load a combo box of all the Clients, so that the user can also pick up (and use) information that is currently associated with other clients.
When I load the combo box of all Clients, I also want to set the Combo box to show the specified client, for continuity. I can't seem to work out how to do this!
A brief overview of how I load the combo box is as follows:
<code> Dim strProc As String = "usp_ClientSubDetails_LoadControls"
Dim dsClients As New DataSet
Dim drClients As DataRow
Dim iRowCtr As Integer = 0
Dim iSelectionVal As Integer = 0
Dim iLoop As Integer ' to find the client in the combo box
'return dataset with client list in it
If Not fncConnectSelectDataset(strProc, CommandType.StoredProcedure, dsClients, sysSystemData.SchedulerDb) Then
strError = strProc
Return False
End If
'make sure there's records in the table
If dsClients.Tables(0).Rows.Count = 0 Then
strError = "No Rows Returned"
Return False
End If
For Each drClients In dsClients.Tables(0).Rows
'DataLoader is a class that has an ID property and a DisplayValue property
Me.cboClients.Items.Add(New DataLoader(drClients.Item(0), drClients.Item(1)))
Next
Me.cboClients.DisplayMember = "DisplayValue"
Me.cboClients.ValueMember = "ID"
</code> <font color="Black" face="Verdana">This gives me a combo box loaded with a bunch of DataLoader objects. By doing </font> CType(cboClients.SelectedItem,DataLoader).ID
<font color="Black" face="Verdana"> I can retrieve the ClientID... I just don't know how to set it, so that if I've told the Form to load details for ClientID 15, it also selects ClientID 15 from the combo box.<br />
<br />
Your help is gratefully appreciated.<br />
<br />
Regards,<br />
<br />
Tom<br />
</font>
|
|
|
|
|
try cboClients.Items.FindByText("TheText").Selected = True Or cboClients.Items.FindByValue("TheValue").Selected = True
oops! I think you asked for windows forms. I have answered for asp.net. Sorry.
Last modified: 14-June-2006 6:39:52 AM --
|
|
|
|
|
You're correct, it is Windows Forms.
I can do cboClients.FindValue, but I don't have the string!
|
|
|
|
|
Can't you use
Overloads Public Function FindStringExact(String) As Integer
|
|
|
|
|
I may well be being incredibly dense, but I don't know the string; I only know the ID of the Client. So I wouldn't have a String to pass the function, right?
Thanks for your help so far!
Tom
|
|
|
|
|
Maybe you could loop through each of the elements in the combobox and set the Item with the client id selected.
Something like this...
Pseudocode
for each item in combobox.items<br />
if item.value = clientid then<br />
item.selected = true<br />
end if
|
|
|
|
|
Thanks Dinuj... Your pseudocode got me there in the end....
Dim dl As DataLoader
For Each dl In cboClients.Items
If dl.ID = ClientID Then
cboClients.SelectedItem = dl
End If
Next Nice one! Give this man a cigar!!
Regards,
Tom
|
|
|
|
|
mincefish wrote: Nice one! Give this man a cigar!!
Glad to be of your help.
|
|
|
|
|
hi i new on this forums and one of beginner in visual basic programming
i need some help 4 my project:
1.what should i do to crop a part of image/picture in picture box
2.how make a color filter in picture?
3.what color in pixel(x,y) and mark it?
thanx a lot
ndox
yahikjsaklfjsdakldxznvc,xznvklsdjfksdcklsdjfklsdjfklsdjfkljsdlkfjsdlk
|
|
|
|
|
1 - use DrawImage on the graphics class to make a cropped copy. Or better yet, ditch the picture box and draw it yourself.
2 and 3 - read my image processing for dummies articles, they are on this site.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
what about automatically crop/copy,while we run the program there are some part of my picture
if u could give me some related program i really apreciate it
thanx
ndox
|
|
|
|
|
Hi,
I wanted to get the Title of MSI file..
For eg. For every MSI file in C:\Windows\Installer\ , I want to check title of every MSI.. like xyz.msi->right click on it->select properties ->select 'summary' -> get title/subject.
can anybody help ?
thanks in advance.
Supriya
|
|
|
|
|
hi guys
I have an access database password protected
what should I change on this code
to pass the password on runtime
Dim crReportDocument As CC
crReportDocument = New CC
Dim ss As String = Application.StartupPath()
Dim logOnInfo As New CrystalDecisions.Shared.TableLogOnInfo
'logOnInfo.ConnectionInfo.ServerName = ss & "\\dbb.mdb"
logOnInfo.ConnectionInfo.ServerName = ss & "\\db.mdb"
crReportDocument.Database.Tables("fmTab").ApplyLogOnInfo(logOnInfo)
CrystalReportViewer1.ReportSource = crReportDocument
thanks alot
Marina f. maayah
MffM
maayah2000@yahoo.com
|
|
|
|
|
|
Hi,
i am doinge a project in vb 6.0 in which i call a exe which is in vb.net.it works fine at developing machine but when i made set up and installed on other machine it,application gives error in calling this vb.net exe. the error is
Application has generated an exception that could not be handled
Process id=0x324(804),Thread id=0x360(864).
click OK to terminate the application
click CANCEL to debug the application
when i click cancel it debug and gfives error
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in HyDwV410AutoCost.exe
Thanks
|
|
|
|
|
In your first .EXE, you probably did not specify the full path to the .EXE you wanted to launch. You probably just specified the filename without any path information, didn't you?
Always, always, always, build and specify full paths to any files you want to use. Never assume that the "current directory" is what you think its supposed to be, because chances are, it's not. Just like you've just found out with the error that your getting.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I think path is not the problem because after installing on client computer its not working then i copied the wanted exe file to the folder in program files where this application installed then its working. I don't why its not workinf when installed.
Thank You
Thanks
|
|
|
|
|
Because you didn't include the .EXE as an extra file in the Setup properly, look for something that says "Additional files". You either didn't add it at all or you added it, but its destination is the wrong folder.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 7:29 Thursday 15th June, 2006
|
|
|
|
|
i think you are right! this thing may solve my problem.
Thanks very much
Thanks
|
|
|
|