Re: Is my SID's octet string correct? I can't find AD object with it.



Are you sure the search base and scope are the same? That's the only reason
why I think it could be different. There is also no real point in adding
(objectCategory=computer) on your filter, as SID is unique and is also
indexed.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"Pucca" <Pucca@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:02BA57F2-18F2-4121-B0C2-B24EE3E6C703@xxxxxxxxxxxxxxxx
Hi, I'm using vs2005, .net 2.0 on win2k server.

Here I'm searching for a Computer object in AD using the sid that I
translate to octet string format for use with DirectorySearcher but it's
not
finding it. But I see it using the ldp.exe. Is there someting wrong with
my
filter or is the problem with the octet string?

sid in sddl: sid = "S-1-5-21-1993962763-879983540-725345543-2608"
searchSID (sid octet string) =
"\\01\\05\\00\\00\\00\\00\\00\\05\\15\\00\\00\\00\\0B\\75\\D9\\76\\B4\\7B\\73\\34\\07\\E5\\3B\\2B\\30\\0A\\00\\00"
My search filter = "(&(objectClass=computer)(objectSid =
\\01\\05\\00\\00\\00\\00\\00\\05\\15\\00\\00\\00\\0B\\75\\D9\\76\\B4\\7B\\73\\34\\07\\E5\\3B\\2B\\30\\0A\\00\\00))"


'for (index = 1; index < dsReport.Tables["PadComputers"].Rows.Count;
index++)
{
dsReport.Tables["PadComputers"].Rows[index]["meetingName"] =

dsReport.Tables["PadComputers"].Rows[index]["meetingName"].ToString().Replace("$",
"");//Remove the trailing $ of the computer name
sid = dsReport.Tables["PadComputers"].Rows[index]["cn"].ToString();
searchSID = CUnityDS.SearchFilterSID(sid);

dsAD.Filter = "(&(objectClass=computer)" + "(objectSid = " + searchSID
+
"))";
srFound = dsAD.FindOne();
if (srFound != null)
{
DataRow newRow = dsReport.Tables["AdComputers"].NewRow();
AdDe = srFound.GetDirectoryEntry();
newRow["objectSid"] = sid;
newRow["cn"] = AdDe.Properties["cn"].Value.ToString();
if (AdDe.Properties["operatingSystem"].Value != null)
newRow["operatingSystem "] =
AdDe.Properties["operatingSystem"].Value.ToString();
if (AdDe.Properties["operatingSystemVersion"].Value != null)
newRow["operatingSystemVersion"] =
AdDe.Properties["operatingSystemVersion"].Value.ToString();
dsReport.Tables["AdComputers"].Rows.Add(newRow);
}
else
continue;
}
--
Thanks.


.