Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get User or Group by objectSID Filter

1,149 views
Skip to first unread message

SD

unread,
May 16, 2006, 10:28:52 AM5/16/06
to
Hi,

I would like in c# get a user or a group using objectSID ref.

sample:
******
DirectoryEntry de = Utility.GetDirectoryObject();

DirectorySearcher deSearch = new DirectorySearcher();

deSearch.SearchRoot = de;

deSearch.Filter = "(&(objectClass=group)(objectSid=" + SID + "))";

SearchResult result = deSearch.FindOne();

My problem :
**********
I have a SID value in byte[] type. What sort of string value I have to put
in my filter and how to obtain it?

Thanks a lot

SD

Joe Kaplan (MVP - ADSI)

unread,
May 16, 2006, 10:59:46 AM5/16/06
to
We have some good coverage of this topic in our new book, which you can find
linked to here:

www.directoryprogramming.net

Basically, a binary LDAP filter is constructed by taking each byte and
converting it to a hex character pair, preceding each byte with a "\". You
can use the .NET "X2" format string do this.

There is a function in the code samples from the book called
BuildFilterOctetString which you can download from the site above that
demonstrates this.

Joe K.

"SD" <raspou...@hotmail.com> wrote in message
news:ur$WjTPeG...@TK2MSFTNGP05.phx.gbl...

SD

unread,
May 16, 2006, 12:40:05 PM5/16/06
to
Merci bcp çà fonctionne.

Cdt,

SD

"Joe Kaplan (MVP - ADSI)" <joseph....@removethis.accenture.com> a écrit
dans le message de news: uk5IMkPe...@TK2MSFTNGP02.phx.gbl...

SD

unread,
May 16, 2006, 12:40:39 PM5/16/06
to
Excuse-me.
I said Thanks.
Best regards
Sd

"Joe Kaplan (MVP - ADSI)" <joseph....@removethis.accenture.com> a écrit
dans le message de news: uk5IMkPe...@TK2MSFTNGP02.phx.gbl...

Joe Richards [MVP]

unread,
May 16, 2006, 12:49:46 PM5/16/06
to
Psst... change objectclass=group to objectcategory=group


--
Joe Richards Microsoft MVP Windows Server Directory Services
Author of O'Reilly Active Directory Third Edition
www.joeware.net


---O'Reilly Active Directory Third Edition now available---

http://www.joeware.net/win/ad3e.htm

0 new messages