Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. System Admin
  4. NetShareGetInfo - returns ERROR_ACCESS_DENIED

NetShareGetInfo - returns ERROR_ACCESS_DENIED

Scheduled Pinned Locked Moved System Admin
sysadminjsonhelpquestion
2 Posts 1 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I am using this API to retrieve the Network Share Information on another machine. Both the machines have been logged on as "Administrator".. But the return status of this API is always "ERROR_ACCESS_DENIED". Does anybody know why? The syntax of my call is as follows: char szPath[255]; WCHAR wcHostName[255]; WCHAR wcShareName[255]; if ( strHost.CompareNoCase(strHostName) == 0 ) MultiByteToWideChar( CP_ACP, 0, strHostName, -1, wcHostName,255 ); else MultiByteToWideChar( CP_ACP, 0, strIP, -1, wcHostName,255 ); MultiByteToWideChar( CP_ACP, 0, strShareName, -1, wcShareName,255 ); PSHARE_INFO_502 BufPtr; NET_API_STATUS res; if ( (res = NetShareGetInfo( (char*)wcHostName, (char*)wcShareName, 502, (LPBYTE *)&BufPtr )) == ERROR_SUCCESS ) { WideCharToMultiByte( CP_ACP, 0, (const unsigned short*)BufPtr->shi502_path, -1, szPath, 255, NULL, NULL ); m_strFileName = szPath; int nLen = m_strFileName.GetLength(); if ( m_strFileName.GetAt(nLen-1) != '\\' ) m_strFileName += '\\'; m_strFileName += strUNCFile; NetApiBufferFree(BufPtr); } else { strErrors += "Unable to convert UNC Name to Local name \n"; bOk = false; } Ramesh S

    L 1 Reply Last reply
    0
    • L Lost User

      I am using this API to retrieve the Network Share Information on another machine. Both the machines have been logged on as "Administrator".. But the return status of this API is always "ERROR_ACCESS_DENIED". Does anybody know why? The syntax of my call is as follows: char szPath[255]; WCHAR wcHostName[255]; WCHAR wcShareName[255]; if ( strHost.CompareNoCase(strHostName) == 0 ) MultiByteToWideChar( CP_ACP, 0, strHostName, -1, wcHostName,255 ); else MultiByteToWideChar( CP_ACP, 0, strIP, -1, wcHostName,255 ); MultiByteToWideChar( CP_ACP, 0, strShareName, -1, wcShareName,255 ); PSHARE_INFO_502 BufPtr; NET_API_STATUS res; if ( (res = NetShareGetInfo( (char*)wcHostName, (char*)wcShareName, 502, (LPBYTE *)&BufPtr )) == ERROR_SUCCESS ) { WideCharToMultiByte( CP_ACP, 0, (const unsigned short*)BufPtr->shi502_path, -1, szPath, 255, NULL, NULL ); m_strFileName = szPath; int nLen = m_strFileName.GetLength(); if ( m_strFileName.GetAt(nLen-1) != '\\' ) m_strFileName += '\\'; m_strFileName += strUNCFile; NetApiBufferFree(BufPtr); } else { strErrors += "Unable to convert UNC Name to Local name \n"; bOk = false; } Ramesh S

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      i'm not sure what you mean when you say "both machines are logged on as administrator". It doesn't matter who is logged in on the other machine. Also, just because you're administrator on your machine you don't get admin privs on the other machine -- that would be quite a security hole! For this api to work, you must be logged into an account recognized as an administrator (or power user? i forget...) account by the machine to which this api is directed.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups