advapi32

Why might LsaAddAccountRights return STATUS_INVALID_PARAMETER?

Here's some C# source code which implements an unmanaged DLL (advapi32). public void AddPrivileges(string account, string privilege) { IntPtr pSid = GetSIDInformation(account); LSA_UNICODE_STRING[] privileges = new LSA_UNICODE_STRING[1]; privileges[0] = InitLsaString(privilege); uint ret = Win32Sec.LsaAddAccountRights(ls...

Where can I find a good example of ReportEvent function usage?

As with most "legacy" MSDN pages, the page for ReportEvent has too little information for me to make much sense of it. I've tried searching, but can't find a good, clean, simple example of the function's usage. Could anyone suggest one? ...

Creating roaming user profiles programmatically on Windows 2008

Problem: Logon and load profile via LoadUserProfile API for a roaming user is not creating proper profile. This only happens under Windows 2008 (UAC off and on). Login using standard windows logon works correctly and same code works correctly on Windows 2003. Logs: http://drop.io/6t2b3f3 ETL of user profile service created via com...

Getting security information for remote registry keys?

According to the documentation for API function GetNamedSecurityInfo, it can get information from the following objects: Local or remote files or directories on an NTFS file system Local or remote printers Local or remote Windows services Network shares Registry keys Semaphores, events, mutexes, and waitable timers File-mapping objects...

I successfully called advapi32's LsaEnumerateAccountRights() from C#. Now how do I unmarshal the array of LSA_UNICODE_STRING it returns?

It's a pointer to an array of LSA_UNICODE_STRING structures. I found some code that does the inverse, i.e., create a LSA_UNICODE_STRING from a C# string. You can see that in the helper code section below. What I have up to and including the call to LsaEnumerateAccountRights() seems to work just fine. Sensible values are returned for the...

How to impersonate another user?

Hi there I'm working on an ASP.net app and i'm trying to impersonate a user I'm creating a windowsIdentity with a token WindowsIdentity winId = new WindowsIdenty( token ); this token was got by calling the un managed code [DllImport("advapi32.dll")] public static extern int LogonUserA(String lpszUserName, String lpszDomain, ...

want to give "logon as a service " rights to the account

i have found a solution using LsaAddAccountRights() win32 api but i was not able to figure out what parameters to give. Here is the code http://www.roelvanlisdonk.nl/?p=1151 Thanks ...

Calling AuditQuerySystemPolicy() (advapi32.dll) from C# returns "The parameter is incorrect"

The sequence is like follows: Open a policy handle with LsaOpenPolicy() (not shown) Call LsaQueryInformationPolicy() to get the number of categories; For each category: Call AuditLookupCategoryGuidFromCategoryId() to turn the enum value into a GUID; Call AuditEnumerateSubCategories() to get a list of the GUIDs of all subcategories; Ca...

What is this (C/C++) program doing?

It's calling these API functions (advapi32.dll) with these parameters: CryptCreateHash ( 3275488, 32771, 0, 0, 1243424 ); CryptHashData ( 3203040, 'UY30930037661', 13, 0 ); CryptCreateHash ( 3276304, 32771, 0, 0, 46463812 ); CryptHashData ( 3203296, '-585164138661', 10, 0 ); CryptCreateHash ( 3276304, 32771, 0, 0, 46463808 ); CryptH...