Jump to content
Xtreme .Net Talk

sjesweak

Members
  • Posts

    5
  • Joined

  • Last visited

sjesweak's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. sjesweak

    Exec

    ok great thx .. i never thought to look in the diagnostic area hehe. What would you use if you have to supply a password to the command prompt after running an application with this... such as with the 'runas' command?
  2. sjesweak

    Exec

    Is there anything in the .NET Framework that worked like the exec family in C and if so does anyone have any examples on it?
  3. Hi everyone - I'm trying to change a name associated with a file using SetNamedSecurityInfo. The parameters I'm passing in are C:\temp\test.txt for path and "tommy boy" for name. I created an accoun on my Windows XP Professional and created the test.txt file using my admin account. When i display the security information it does show that it's mine. When I try and change the account name that is associated with the test.txt file it gives me an error code of 87 at dRtnErrorCode with SetNamedSecurityInfo.... anyone have any idea? int setOwner(char* path, char* name){ DWORD dwRtnCode = 0; LPTSTR pSid, DomainName; DWORD dwSid = 1, dwDomainName = 1; BOOL bRtnBool = TRUE; LPTSTR fileName = path; LPCTSTR acctName = name; SID_NAME_USE eUse = SidTypeUnknown; // Get Buffer Size for LookupAccountName bRtnBool = LookupAccountName( NULL, acctName, (PSID) &pSid, (LPDWORD) &dwSid, (LPTSTR) &DomainName, (LPDWORD) &dwDomainName, &eUse); // Reallocate memory for the buffers. pSid = (char *)GlobalAlloc( GMEM_FIXED, dwSid); // Check GetLastError for GlobalAlloc error condition. if (pSid == NULL) { DWORD dwErrorCode = 0; dwErrorCode = GetLastError(); _tprintf(TEXT("GlobalAlloc error = %d\n"), dwErrorCode); return -1; } DomainName = (char *)GlobalAlloc( GMEM_FIXED, dwDomainName); // Check GetLastError for GlobalAlloc error condition. if (DomainName == NULL) { DWORD dwErrorCode = 0; dwErrorCode = GetLastError(); _tprintf(TEXT("GlobalAlloc error = %d\n"), dwErrorCode); return -1; } // Second call to LookupAccountName to get the account name. bRtnBool = LookupAccountName( NULL, // name of local or remote computer acctName, // name of account pSid, // sid buffer (LPDWORD)&dwSid, // size of sid buffer DomainName, // domain name (LPDWORD)&dwDomainName, // size of domain name buffer &eUse); // SID type // Check GetLastError for LookupAccountName error condition. if (bRtnBool == FALSE) { DWORD dwErrorCode = 0; dwErrorCode = GetLastError(); if (dwErrorCode == ERROR_NONE_MAPPED) _tprintf(TEXT("SID not found for specified Account Name.\n")); else _tprintf(TEXT("Error in LookupAccountName.\n")); return -1; } else if (bRtnBool == TRUE){ // Set the owner SID of the file. dwRtnCode = SetNamedSecurityInfo( fileName, SE_FILE_OBJECT, OWNER_SECURITY_INFORMATION, &pSid, NULL, NULL, NULL); // Check GetLastError for SetNamedSecurityInfo error condition. if (dwRtnCode != ERROR_SUCCESS) { DWORD dwErrorCode = 0; dwErrorCode = GetLastError(); _tprintf(TEXT("SetNamedSecurityInfo error = %d\n"), dwErrorCode); return -1; } // Print the account name. displayOwner(path); } return 0; }
  4. Console::WriteLine(S"{0} is not a valid file or directory.", path); I know the {0} is where the 'path' variable is placed can someone please tell me how the {0} works and what all this can be used for.
  5. I've been looking at chunks of code and dealing with string assignments in C++. String* myLog = S"myNewLog"; What is the 'S' before "myNewLog"; needed for? Is it involved with the pointer of String*?
×
×
  • Create New...