当前位置: 首页>>代码示例>>C++>>正文


C++ LookupAccountSid函数代码示例

本文整理汇总了C++中LookupAccountSid函数的典型用法代码示例。如果您正苦于以下问题:C++ LookupAccountSid函数的具体用法?C++ LookupAccountSid怎么用?C++ LookupAccountSid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了LookupAccountSid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PORT_ACCESS_FROM_ENV

BOOLEAN GetInfo
(JNIEnv * jenv, PSID sid, LPSTR* ppName, LPSTR* ppDomain) 
{
	PORT_ACCESS_FROM_ENV (jenv);

	DWORD dwNameSize = 0;
	DWORD dwDomainNameSize = 0;
	SID_NAME_USE snu;
	if( !LookupAccountSid(NULL, sid, NULL, &dwNameSize, NULL, &dwDomainNameSize, &snu)) {
		if( ERROR_INSUFFICIENT_BUFFER != GetLastError() ) {
			return FALSE;
		}
	}
	*ppName = (LPSTR)hymem_allocate_memory(dwNameSize);
	if( NULL == ppName ) {
		return FALSE;
	}
	*ppDomain = (LPSTR)hymem_allocate_memory(dwDomainNameSize);
	if( NULL == ppName ) {
		DWORD err = GetLastError();
		hymem_free_memory(*ppName);
		SetLastError(err);
		return FALSE;
	}
	if( !LookupAccountSid(NULL, sid, *ppName, &dwNameSize, *ppDomain, &dwDomainNameSize, &snu)) {
		DWORD err = GetLastError();
		hymem_free_memory(*ppName);
		hymem_free_memory(*ppDomain);
		SetLastError(err);
		return FALSE;
	}

	return TRUE;
}
开发者ID:chengkaizone,项目名称:cn1,代码行数:34,代码来源:authwin32.c

示例2: userSID

	std::wstring userSID() const {
		if (pevlr_->UserSidOffset == 0)
			return L" ";
		PSID p = NULL; // = reinterpret_cast<const void*>(reinterpret_cast<const BYTE*>(pevlr_) + + pevlr_->UserSidOffset);
		DWORD userLen = 0;
		DWORD domainLen = 0;
		SID_NAME_USE sidName;

		LookupAccountSid(NULL, p, NULL, &userLen, NULL, &domainLen, &sidName);
		LPTSTR user = new TCHAR[userLen + 10];
		LPTSTR domain = new TCHAR[domainLen + 10];

		LookupAccountSid(NULL, p, user, &userLen, domain, &domainLen, &sidName);
		user[userLen] = 0;
		domain[domainLen] = 0;
		std::wstring ustr = user;
		std::wstring dstr = domain;
		delete[] user;
		delete[] domain;
		if (!dstr.empty())
			dstr = dstr + L"\\";
		if (ustr.empty() && dstr.empty())
			return L"missing";

		return dstr + ustr;
	}
开发者ID:mickem,项目名称:nscp,代码行数:26,代码来源:eventlog_record.hpp

示例3: get_account_sid

int get_account_sid(PSID pSid,char * account,size_t acclen,
		    SID_NAME_USE * peUse)
{
  DWORD dwAccountLen = 0;
  DWORD dwDomainLen = 0;
  char * szAccountName = NULL;
  char * szDomainName = NULL;
  DWORD dwRetLen = 0;
  

  LookupAccountSid(NULL,pSid,
		   szAccountName,&dwAccountLen,
		   szDomainName,&dwDomainLen,
		   peUse);


  szAccountName = (char *) malloc(dwAccountLen);

  if (szAccountName == NULL){
    SetLastError(ERROR_OUTOFMEMORY);
    return (-1);
  }

  szDomainName = (char *) malloc(dwDomainLen);

  if (szDomainName == NULL){
    free(szAccountName);
    SetLastError(ERROR_OUTOFMEMORY);
    return (-1);
  }

  if (0 == LookupAccountSid(NULL,pSid,
			    szAccountName,&dwAccountLen,
			    szDomainName,&dwDomainLen,
			    peUse)){
    if (GetLastError() == ERROR_NONE_MAPPED){
      get_textual_sid(pSid,account,acclen);
      goto free_mem;
    }
    free(szAccountName);
    free(szDomainName);
    return (-1);
  }



  if (dwDomainLen <= 1)
    _snprintf(account,acclen,"%s",szAccountName);
  else
    _snprintf(account,acclen,"%s\\%s",szDomainName,szAccountName);
  
  
 free_mem:
  free(szAccountName);
  free(szDomainName);

  return (0);
}
开发者ID:zaharovmag,项目名称:win-util,代码行数:58,代码来源:win.c

示例4: PrintUserName

static void PrintUserName(PDOKAN_FILE_INFO DokanFileInfo) {
  HANDLE handle;
  UCHAR buffer[1024];
  DWORD returnLength;
  WCHAR accountName[256];
  WCHAR domainName[256];
  DWORD accountLength = sizeof(accountName) / sizeof(WCHAR);
  DWORD domainLength = sizeof(domainName) / sizeof(WCHAR);
  PTOKEN_USER tokenUser;
  SID_NAME_USE snu;

  handle = DokanOpenRequestorToken(DokanFileInfo);
  if (handle == INVALID_HANDLE_VALUE) {
    DbgPrint(L"  DokanOpenRequestorToken failed\n");
    return;
  }

  if (!GetTokenInformation(handle, TokenUser, buffer, sizeof(buffer),
                           &returnLength)) {
    DbgPrint(L"  GetTokenInformaiton failed: %d\n", GetLastError());
    CloseHandle(handle);
    return;
  }

  CloseHandle(handle);

  tokenUser = (PTOKEN_USER)buffer;
  if (!LookupAccountSid(NULL, tokenUser->User.Sid, accountName, &accountLength,
                        domainName, &domainLength, &snu)) {
    DbgPrint(L"  LookupAccountSid failed: %d\n", GetLastError());
    return;
  }

  DbgPrint(L"  AccountName: %s, DomainName: %s\n", accountName, domainName);
}
开发者ID:cnhup,项目名称:dokany,代码行数:35,代码来源:mirror.c

示例5: GetProcessToken

HRESULT GetProcessToken(DWORD dwProcessID, LPHANDLE token, DWORD nUserNameMax, LPWSTR szwUserName, DWORD nUserDomainMax, LPWSTR szwUserDomain) {
	HANDLE hProcess=OpenProcess(PROCESS_DUP_HANDLE|PROCESS_QUERY_INFORMATION,TRUE,dwProcessID); 
	if (!hProcess) throw std::runtime_error("OpenProcess failed");
	HRESULT retval = S_OK;
	HANDLE hToken = INVALID_HANDLE_VALUE;
	if (!OpenProcessToken(hProcess, TOKEN_DUPLICATE | TOKEN_QUERY, &hToken)) retval = HRESULT_FROM_WIN32(GetLastError());
	else {
		BYTE buf[MAX_PATH]; DWORD dwRead = 0;
		if (!GetTokenInformation(hToken, TokenUser, buf, MAX_PATH, &dwRead)) retval = HRESULT_FROM_WIN32(GetLastError());
		else {
			TOKEN_USER *puser = reinterpret_cast<TOKEN_USER*>(buf);
			SID_NAME_USE eUse;
			if (!LookupAccountSid(NULL, puser->User.Sid, szwUserName, &nUserNameMax, szwUserDomain, &nUserDomainMax, &eUse))
				retval = HRESULT_FROM_WIN32(GetLastError());
			}
		if (FAILED(retval)) return retval;
		if (!DuplicateTokenEx(hToken, 
			TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE, 
			NULL, SecurityImpersonation, TokenPrimary,token))
			retval = HRESULT_FROM_WIN32(GetLastError());
		else  retval = S_OK;
		CloseHandle(hToken);
		}
	return retval;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:25,代码来源:ProcessStarter_win.cpp

示例6: GetFileOwner

int GetFileOwner (const char *Computer, const char *Name, char *Owner)
{
    SECURITY_INFORMATION si = OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION;
    SECURITY_DESCRIPTOR *sd;
    char sddata[500];
    *Owner=0;
    sd=(SECURITY_DESCRIPTOR *)sddata;

    char AnsiName[NM];
    OemToChar(Name,AnsiName);
    SetFileApisToANSI();
    DWORD Needed;
    int GetCode=GetFileSecurity(AnsiName,si,sd,sizeof(sddata),&Needed);
    SetFileApisToOEM();

    if (!GetCode || (Needed>sizeof(sddata)))
        return(FALSE);
    PSID pOwner;
    BOOL OwnerDefaulted;
    if (!GetSecurityDescriptorOwner(sd,&pOwner,&OwnerDefaulted))
        return(FALSE);
    char AccountName[200],DomainName[200];
    DWORD AccountLength=sizeof(AccountName),DomainLength=sizeof(DomainName);
    SID_NAME_USE snu;
    if (!LookupAccountSid(Computer,pOwner,AccountName,&AccountLength,DomainName,&DomainLength,&snu))
        return(FALSE);
    CharToOem(AccountName,Owner);
    return(TRUE);
}
开发者ID:BackupTheBerlios,项目名称:far-unlimited-svn,代码行数:29,代码来源:FAR_SF.cpp

示例7: FormatUserName

BOOL FormatUserName(PSID sid, TCHAR *userName, size_t cchMax)
{
    BOOL success = FALSE;

    TCHAR accountName[512];
    DWORD accountNameLength = SIZEOF_ARRAY(accountName);
    TCHAR domainName[512];
    DWORD domainNameLength = SIZEOF_ARRAY(domainName);
    SID_NAME_USE eUse;
    BOOL bRet = LookupAccountSid(NULL, sid, accountName, &accountNameLength,
                                 domainName, &domainNameLength, &eUse);

    if(bRet)
    {
        StringCchPrintf(userName, cchMax, _T("%s\\%s"), domainName, accountName);
        success = TRUE;
    }
    else
    {
        LPTSTR stringSid;
        bRet = ConvertSidToStringSid(sid, &stringSid);

        if(bRet)
        {
            StringCchCopy(userName, cchMax, stringSid);

            LocalFree(stringSid);
            success = TRUE;
        }
    }

    return success;
}
开发者ID:RenniePet,项目名称:explorerplusplus,代码行数:33,代码来源:Helper.cpp

示例8: _tcscpy

CToolDumper::CSelectProcessDialog::CListElement::CListElement(PROCESSENTRY32* pProcess)
{
	//запомнить информацию
	mProcessID=pProcess->th32ProcessID;
	mParentProcessID=pProcess->th32ParentProcessID;
	_tcscpy(mszBaseName,pProcess->szExeFile);

	//получить дополнительную информацию
	HANDLE hProcess=OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,mProcessID);
	//флаг успеха получения информации об учётной записи
	BOOL AccountResulted=FALSE;
	if(hProcess)
	{
		//получить полное имя файла процесса
		GetProcessImageFileName(hProcess,mszFullName,(MAX_PATH-1)*sizeof(TCHAR));
		mszFullName[MAX_PATH-1]=0;

		//получить информацию об использовании памяти процессом
		mMemoryInfoExist=GetProcessMemoryInfo(hProcess,&mMemoryInfo,sizeof(mMemoryInfo));

		//получить маркер защиты процесса
		HANDLE hProcessToken;
		if(OpenProcessToken(hProcess,TOKEN_QUERY,&hProcessToken))
		{
			//получить информацию о пользователе
			DWORD NeededSize;
			if(!GetTokenInformation(hProcessToken,TokenUser,NULL,0,&NeededSize))
			{
				TOKEN_USER* pUserInfo=(TOKEN_USER*)new BYTE[NeededSize];
				if(GetTokenInformation(hProcessToken,TokenUser,pUserInfo,NeededSize,&NeededSize))
				{
					//получить имя учётной записи, под которой работает процесс
					DWORD AccountNameLength=MAX_PATH;
					DWORD AccountDomainNameLength=MAX_PATH;
					SID_NAME_USE AccountUse;
					if(LookupAccountSid(NULL,pUserInfo->User.Sid,mszAccountName,&AccountNameLength,mszAccountDomainName,&AccountDomainNameLength,&AccountUse))
						//установить флаг результата
						AccountResulted=TRUE;
				}
				delete [] (BYTE*)pUserInfo;
			}

			CloseHandle(hProcessToken);
		}

		//закрыть описатель процесса
		CloseHandle(hProcess);
	}
	else
	{
		mszFullName[0]=0;
		mMemoryInfoExist=FALSE;
	}
	//если неудача с получением имени учётной записи, очистить строки
	if(!AccountResulted)
	{
		mszAccountName[0]=0;
		mszAccountDomainName[0]=0;
	}
}
开发者ID:revel8n,项目名称:code0,代码行数:60,代码来源:tool_dumper.cpp

示例9: hToken

void Helpers::GetCurrentUserAndDomain(std::wstring& strUser, std::wstring& strDomain)
{
	std::unique_ptr<void, CloseHandleHelper> hToken(nullptr);

	{
		HANDLE _hToken = nullptr;

		if ( !::OpenProcessToken(
			::GetCurrentProcess(),
			TOKEN_QUERY,
			&_hToken) )
		{
			Win32Exception::ThrowFromLastError("OpenProcessToken");
		}

		hToken.reset(_hToken);
	}

	DWORD dwReturnLength = 0;

	if ( !::GetTokenInformation(
		hToken.get(),
		TokenUser,
		nullptr,
		0,
		&dwReturnLength ) )
	{
		if( GetLastError() != ERROR_INSUFFICIENT_BUFFER )
			Win32Exception::ThrowFromLastError("GetTokenInformation");
	}

	std::unique_ptr<BYTE[]> tu(new BYTE[dwReturnLength]);

	if ( !::GetTokenInformation(
		hToken.get(),
		TokenUser,
		tu.get(),
		dwReturnLength,
		&dwReturnLength ) )
	{
			Win32Exception::ThrowFromLastError("GetTokenInformation");
	}

	wchar_t szUser[CRED_MAX_STRING_LENGTH + 1] = L"";
	wchar_t szDomain[CRED_MAX_STRING_LENGTH + 1] = L"";
	DWORD dwUserLen = static_cast<DWORD>(ARRAYSIZE(szUser));
	DWORD dwDomainLen = static_cast<DWORD>(ARRAYSIZE(szDomain));
	SID_NAME_USE snu;

	// Retrieve user name and domain name based on user's SID.
	if( !LookupAccountSid(NULL, reinterpret_cast<TOKEN_USER*>(tu.get())->User.Sid, szUser, &dwUserLen, szDomain, &dwDomainLen, &snu) )
	{
		Win32Exception::ThrowFromLastError("LookupAccountSid");
	}

	strUser = szUser;
	strDomain = szDomain;
}
开发者ID:MussaratAziz,项目名称:console,代码行数:58,代码来源:Helpers.cpp

示例10: CloseHandle

CString CAppBarManager::GetCurrentUserName(LPTSTR lpstrAppName)
{   
	HANDLE hToken;   

	// 得到shell的token   
	if(!GetTokenByName(hToken, lpstrAppName))   
	{   
		return FALSE;   
	}   
	DWORD cbti = 0;   
	PTOKEN_USER ptiUser = NULL;   
	SID_NAME_USE snu;   

	// 取得所需空间大小   
	if (GetTokenInformation(hToken, TokenUser, NULL, 0, &cbti))     
	{   
		CloseHandle(hToken);   
		return FALSE;   
	}   

	// 分配空间   
	ptiUser = (PTOKEN_USER) HeapAlloc(GetProcessHeap(), 0, cbti);   
	if(!ptiUser)   
	{   
		CloseHandle(hToken);   
		return FALSE;   
	}   

	// 取得token信息   
	if (!GetTokenInformation(hToken, TokenUser, ptiUser, cbti, &cbti))   
	{   
		CloseHandle(hToken);   
		HeapFree(GetProcessHeap(), 0, ptiUser);   
		return FALSE;   
	}   

	TCHAR szUser[MAX_PATH];   
	TCHAR szDomain[MAX_PATH];   
	DWORD nUser = MAX_PATH;   
	DWORD nDomain = MAX_PATH;   

	// 根据用户的sid得到用户名和domain   
	if (!LookupAccountSid(NULL, ptiUser->User.Sid, szUser, &nUser,     
		szDomain, &nDomain, &snu))   
	{   
		CloseHandle(hToken);   
		HeapFree(GetProcessHeap(), 0, ptiUser);   
		return FALSE;   
	}   

	CloseHandle(hToken);   
	HeapFree(GetProcessHeap(), 0, ptiUser);

	CString strUserName(szUser);

	return strUserName;
}   
开发者ID:harrysun2006,项目名称:ag_Client,代码行数:57,代码来源:AppBarManager.cpp

示例11: OpenProcess

bool Win32::ProcessInfo::GetUserAndDomainName(CString& cszUsername, CString& cszRefDomainName)
{
   HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, m_dwProcessId);
   if (hProcess == NULL)
      return false;

   bool bRet = false;
   HANDLE hProcessToken = NULL;
   if (TRUE == OpenProcessToken(hProcess, TOKEN_QUERY, &hProcessToken))
   {
      // get length
      DWORD nLength = 0;
      GetTokenInformation(hProcessToken, TokenUser, NULL, 0, &nLength);

      std::vector<BYTE> vecData(nLength);
      TOKEN_USER* pTokenUser = (TOKEN_USER*)&vecData[0];

      if (TRUE == GetTokenInformation(hProcessToken, TokenUser, pTokenUser, nLength, &nLength))
      {
         DWORD cchName = 0, cchReferencedDomainName = 0;
         LookupAccountSid(NULL, pTokenUser->User.Sid, NULL, &cchName, NULL, &cchReferencedDomainName, NULL);

         // for some unknown reason the direct use of the output parameters don't work, so use
         // local objects here and assign later
         CString cszUsernameL, cszRefDomainNameL;
         SID_NAME_USE eUse;
         LookupAccountSid(NULL, pTokenUser->User.Sid,
            cszUsernameL.GetBuffer(cchName), &cchName,
            cszRefDomainNameL.GetBuffer(cchReferencedDomainName), &cchReferencedDomainName,
            &eUse);

         cszUsernameL.ReleaseBuffer();
         cszRefDomainNameL.ReleaseBuffer();

         cszUsername = cszUsernameL;
         cszRefDomainName = cszRefDomainNameL;
         bRet = true;
      }

      CloseHandle(hProcessToken);
   }

   return bRet;
}
开发者ID:vividos,项目名称:OldStuff,代码行数:44,代码来源:ProcessInfo.cpp

示例12: GetSidName

/* ask a server to translate a SID into a textual representation */
static gunichar2*
GetSidName (gunichar2 *server, PSID sid, gint32 *size)
{
    gunichar2 *uniname = NULL;
    DWORD cchName = 0;
    DWORD cchDomain = 0;
    SID_NAME_USE peUse; /* out */

    LookupAccountSid (server, sid, NULL, &cchName, NULL,
                      &cchDomain, &peUse);

    if ((cchName > 0) && (cchDomain > 0)) {
        gunichar2 *user = g_malloc0 ((cchName + 1) * 2);
        gunichar2 *domain = g_malloc0 ((cchDomain + 1) * 2);

        LookupAccountSid (server, sid, user, &cchName, domain,
                          &cchDomain, &peUse);

        if (cchName > 0) {
            if (cchDomain > 0) {
                /* domain/machine name included (+ sepearator) */
                *size = cchName + cchDomain + 1;
                uniname = g_malloc0 ((*size + 1) * 2);
                memcpy (uniname, domain, cchDomain * 2);
                *(uniname + cchDomain) = '\\';
                memcpy (uniname + cchDomain + 1, user, cchName * 2);
                g_free (user);
            }
            else {
                /* no domain / machine */
                *size = cchName;
                uniname = user;
            }
        }
        else {
            /* nothing -> return NULL */
            g_free (user);
        }

        g_free (domain);
    }

    return uniname;
}
开发者ID:LevNNN,项目名称:mono,代码行数:45,代码来源:mono-security.c

示例13: OpenProcess

//author: yy2better
//email: [email protected]
//获取进程的用户名
BOOL CSecurityTool::GetProcessUser(DWORD dwProcessID, TCHAR *szUserName, DWORD nNameLen)
{
	BOOL fResult  = FALSE;
    HANDLE hProc  = NULL;
	HANDLE hToken = NULL;
	TOKEN_USER *pTokenUser = NULL;
	
	__try
	{
        // Open the process with PROCESS_QUERY_INFORMATION access
        hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessID);
        if (hProc == NULL)
		{
			__leave;
		}
        fResult = OpenProcessToken(hProc, TOKEN_QUERY, &hToken);
        if(!fResult)  
		{
			__leave;
		}
		
		DWORD dwNeedLen = 0;		
		fResult = GetTokenInformation(hToken,TokenUser, NULL, 0, &dwNeedLen);
		if (dwNeedLen > 0)
		{
			pTokenUser = (TOKEN_USER*)new BYTE[dwNeedLen];
			fResult = GetTokenInformation(hToken,TokenUser, pTokenUser, dwNeedLen, &dwNeedLen);
			if (!fResult)
			{
				__leave;
			}
		}
		else
		{
			__leave;
		}

		SID_NAME_USE sn;
		TCHAR szDomainName[MAX_PATH];
		DWORD dwDmLen = MAX_PATH;
		fResult = LookupAccountSid(NULL, pTokenUser->User.Sid, szUserName, &nNameLen,
			szDomainName, &dwDmLen, &sn);
	}
	__finally
	{
		if (hProc)
			::CloseHandle(hProc);
		if (hToken)
			::CloseHandle(hToken);
		if (pTokenUser)
			delete[] (char*)pTokenUser;		
	}
	return fResult;
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:57,代码来源:SecurityTool.cpp

示例14: SIDCacheItem

	SIDCacheItem(const wchar_t *Computer,PSID InitSID)
	{
		Sid=xf_malloc(GetLengthSid(InitSID));
		if(Sid)
		{
			if(CopySid(GetLengthSid(InitSID),Sid,InitSID))
			{
				DWORD AccountLength=0,DomainLength=0;
				SID_NAME_USE snu;
				LookupAccountSid(Computer,Sid,nullptr,&AccountLength,nullptr,&DomainLength,&snu);
				if (AccountLength && DomainLength)
				{
					string strAccountName,strDomainName;
					LPWSTR AccountName=strAccountName.GetBuffer(AccountLength);
					LPWSTR DomainName=strDomainName.GetBuffer(DomainLength);
					if (AccountName && DomainName)
					{
						if(LookupAccountSid(Computer,Sid,AccountName,&AccountLength,DomainName,&DomainLength,&snu))
						{
							strUserName=string(DomainName).Append(L"\\").Append(AccountName);
						}
					}
				}
				else
				{
					LPWSTR StrSid;
					if(ConvertSidToStringSid(Sid, &StrSid))
					{
						strUserName = StrSid;
						LocalFree(StrSid);
					}
				}
			}
		}

		if(strUserName.IsEmpty())
		{
			xf_free(Sid);
			Sid=nullptr;
		}
	}
开发者ID:CyberShadow,项目名称:FAR,代码行数:41,代码来源:fileowner.cpp

示例15: PrintSid

void vncExportACL::PrintSid(PSID psid)
{
    TCHAR name[256], domain[256];
    DWORD cbname = sizeof name, cbdomain = sizeof domain, rc;
    SID_NAME_USE sidUse;

    //!! next line has hardcoded server name !!
    // NULL server name is usually appropriate, though.
    if (LookupAccountSid(NULL, psid, name, &cbname, domain, &cbdomain, &sidUse))
    {
        //Todo: Check if WellKnownSID and reserve special names for them.

        /*		switch ( sidUse )
        		{
        			case SidTypeWellKnownGroup:	type = "well-known group"; break;
        			default:					type = "bad sidUse value"; break;
        		}
        */
        LPWKSTA_INFO_100 wkstainfo = NULL;
        NET_API_STATUS nStatus;
        TCHAR langroup[MAXLEN];
        TCHAR computername[MAXLEN];

        nStatus = NetWkstaGetInfo( 0 , 100 , (LPBYTE *) &wkstainfo);
        if (nStatus == NERR_Success) {
            _tcsncpy(langroup, wkstainfo->wki100_langroup, MAXLEN);
            _tcsncpy(computername, wkstainfo->wki100_computername, MAXLEN);
            langroup[MAXLEN - 1] = _T('\0');
            computername[MAXLEN - 1] = _T('\0');
            // replace computername with a dot
            if (_tcsicmp(computername, domain) == 0)
                _tcscpy(domain,_T("."));
            else if (_tcsicmp(langroup, domain) == 0)
                _tcscpy(domain, _T(".."));
        }
        else
            _tprintf(_T("NetWkstaGetInfo() returned %lu \n"), wkstainfo);

        NetApiBufferFree(wkstainfo);
        wkstainfo = NULL;

        // If domain or username contains whitespace, print enclosing quotes
        if (_tcschr(domain, _T(' ')) || _tcschr(name, _T(' ')))
            _tprintf(_T("\"%s%s%s\"\n"), domain, (domain == 0 || *domain == _T('\0'))? _T(""): _T("\\"), name);
        else
            _tprintf(_T("%s%s%s\n"), domain, (domain == 0 || *domain == _T('\0'))? _T(""): _T("\\"), name);
    }
    else
    {
        rc = GetLastError();
        _tprintf(_T("[%s] *** error %lu\n"), SidToText( psid ), rc);
    }
}
开发者ID:thiagomoreiraboby,项目名称:SuporteOnline,代码行数:53,代码来源:vncExportACL.cpp


注:本文中的LookupAccountSid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。