Last post Apr 11, 2006 04:26 AM by RemarkLima
Apr 06, 2006 05:59 AM|RemarkLima|LINK
I'm trying to find a mailbox from a SID ideally... I get the following code to work lovely:
' First get the SID and SD for the user, which we will need later on.
Dim objUI As
Dim arrSID As Object
objUI.GetSidFromName("AIGGICBL", "MailerM", arrSID)
objUI = Nothing
As New DirectoryEntry("LDAP://Exchnage/o=ExOrg/ou=ExSite/cn=Recipients")
' //searches will be rooted under this OU
'Dim ds As New DirectorySearcher(searchRoot, "(Assoc-NT-Account=" & arrSID & ")")
Dim ds As
New DirectorySearcher(searchRoot, "(sn=Mailer)")
ds.SizeLimit = 1
As SearchResult = Nothing
Dim src As SearchResultCollection
src = ds.FindAll()
If src.Count > 0 Then
sr = src(0)
Is Nothing = False
Basically a carbon VB copy of Dunnry's code in the read me first in this forum... But when I try and search on the "Assoc-NT-Account" with the ArrSID I get a conversion error from Byte() to String.
Any ideas of how to do this?
Apr 06, 2006 01:24 PM|dunnry|LINK
Apr 10, 2006 07:25 AM|RemarkLima|LINK
Thanks for that...
It works in as much as there's no errors but it doesn't show any results from the filter. I can get the LDAP to display the Assoc-NT-Account either so can't "manually" compare the two.
Looking around should the filter string be in a hex format? S-0-etc...?
It's monday morning and my head is feeling a little confused!
Apr 10, 2006 08:12 PM|dunnry|LINK
Apr 11, 2006 04:26 AM|RemarkLima|LINK
Ryan, you are the man!!! Many thanks (again!)
It was my own fault as I missed in the translation of C# to VB that I didn't need to escape the \ so I had \\00\\etc... D'oh!
Now it works like a charm!
Just FYI, I tried to write the Assoc-NT-Account property:
(thinking GetType() would be able to write no problems)
Object reference not set to an instance of an object.
So I can't seem to read the property at all... Sadly.
Still, all working like a charm now! Thanks again!