473,326 Members | 2,010 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,326 software developers and data experts.

Find user by SID

I have a string version of a sid (ex...S-20-220) I need to be able to take
this sid and transfer it over to a name. My question is how do I do this.
I know that in order to search with
System.DirectoryServices.DirectorySearcher I need to have the binary version
of the SID. I've tried to use ConvertStringSidToSid but I think I'm
screwing up the syntax or something. I also saw there is a function out
there called LookupAccountSid. What should I be using to search with the
string SID. Any help would be greatly appreciated and some code examples
would be extremely helpful.

Thank you to every who replys in advance.

Will Bailey
Nov 16 '05 #1
2 6270
Will,

The declaration should look like this:

[DllImport("Advapi32.dll", SetLastError=true)]
public static extern bool ConvertStringSidToSid(String StringSid, ref IntPtr
Sid);

Remember, you need to call LocalFree in order to release the sid. The
declaration for that is as follows:

[DllImport("Kernel32.dll", SetLastError=true)]
public static extern IntPtr LocalFree(IntPtr hMem);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Will Bailey" <me*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a string version of a sid (ex...S-20-220) I need to be able to take this sid and transfer it over to a name. My question is how do I do this.
I know that in order to search with
System.DirectoryServices.DirectorySearcher I need to have the binary version of the SID. I've tried to use ConvertStringSidToSid but I think I'm
screwing up the syntax or something. I also saw there is a function out
there called LookupAccountSid. What should I be using to search with the
string SID. Any help would be greatly appreciated and some code examples
would be extremely helpful.

Thank you to every who replys in advance.

Will Bailey

Nov 16 '05 #2
This project on GotDotNet might help you:
http://www.gotdotnet.com/Community/U...f-e0705af065d9

"Will Bailey" <me*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a string version of a sid (ex...S-20-220) I need to be able to take this sid and transfer it over to a name. My question is how do I do this.
I know that in order to search with
System.DirectoryServices.DirectorySearcher I need to have the binary version of the SID. I've tried to use ConvertStringSidToSid but I think I'm
screwing up the syntax or something. I also saw there is a function out
there called LookupAccountSid. What should I be using to search with the
string SID. Any help would be greatly appreciated and some code examples
would be extremely helpful.

Thank you to every who replys in advance.

Will Bailey

Nov 16 '05 #3

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

Similar topics

9
by: Mayer | last post by:
Hello: I'm running python under cygwin and need to find the drive letter. Cygwin has a way of calling my drives by a name relative to the Cygwin directory, so I get things like /home/user rather...
8
by: pigeon | last post by:
I have 2 users that their client software must be going crazy.. they are sending packets every .02 seconds to the db server... I know this because I stuck a sniffer on teh traffic.. but now i just...
0
by: aredo3604gif | last post by:
The user can dynamically enter and change the rule connection between objects. The rule is a "<" and so given two objects: a < b simply means that b < a can't be set, also it must be a != b. And...
1
by: aredo3604gif | last post by:
On Sun, 10 Apr 2005 19:46:32 GMT, aredo3604gif@yahoo.com wrote: >The user can dynamically enter and change the rule connection between >objects. The rule is a "<" and so given two objects: >a <...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
5
by: Mike Labosh | last post by:
In VB 6, the Form_QueryUnload event had an UnloadMode parameter that let me find out *why* a form is unloading, and then conditionally cancel the event. In VB.NET, the Closing event passes a...
8
by: erick-flores | last post by:
Hello all My code used to work, but now its not working any more. What I am trying to do is find the current user when a forms open. This is the code that used to work: If...
2
by: moondaddy | last post by:
I had to repost this because I had to update and change my msdn alias. I will re-ask the question and clarify a few things that were not clear before. This code is all executed on my dev...
5
by: gnewsgroup | last post by:
In my user control, I would like to find a Label control in the parent page (the page that uses my user control). I need to update that Label.Text when something happens in the user control. I...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.