Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get logged in users SID?

Status
Not open for further replies.

VBProgger

IS-IT--Management
Joined
Mar 21, 2005
Messages
3
Location
FR
I am trying to figure out a way to get the current logged
in users SID. I need this so that when logging an Event
in Event Log that the users account will be properly
associated with the event (instead of showing up as N/A).

Any assistance would be greatly appreciated.

TIA
 
I believe you can use the LookupAccountName API. Quoting from the MSDN documentation,

"The LookupAccountName function accepts the name of a system and an account as input. It retrieves a security identifier (SID) for the account and the name of the domain on which the account was found."
 
I have used the LookupAccountName and I get a full SID. The S-1-0-..... and that is great. Thanks.

However what I need it for is to pass to ReportEvent so that when I write an Event to the Event Log that the User is associated rather than showing N/A. ReportEvent is looking for a Long and I can not find the correct value.

Here is a code snippet if that helps.

Call LogNTEvent("Information from " & App.EXEName, _
EVENTLOG_INFORMATION_TYPE, 1000, lMySid)

' Declaration
Public Sub LogNTEvent(sString As String, iLogType As
Integer, iEventID As Long, ByVal vSidVal As Long)
.
.
.
If ReportEvent(hEventLog, iLogType, 0, iEventID, vSidVal, _
iNumStrings, cbStringSize, hMsgs, hMsgs) = 0 Then
MsgBox GetLastError()
End If

end sub

Any thoughts would be apprecaited.
 
ReportEvent() is looking for a POINTER to the user's sid, NOT the sid itself. You can look thru the FAQs in this forum for a method of producing the address (aka pointer) to the SID returned from LookupAccountName()
 
Thanks. I realized that about two minutes after posting.

What a dolt I am.

Thanks.

 
Hi VBProgger,

Have you got the code that you used to get the SID using LookUpAccountName please?

Thanks in advance
Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top