Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 80275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:16:37+00:00 2026-05-10T21:16:37+00:00

Currently we have a DLL that checks whether a username/password is a valid Windows

  • 0

Currently we have a DLL that checks whether a username/password is a valid Windows user using the Windows API LogonUser method. We need to enhance it so it checks whether the user belongs to a specified group as well. Is there a Windows method that does that?

Given a Windows username and password, find out whether the user belongs to a specified group.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:16:38+00:00Added an answer on May 10, 2026 at 9:16 pm

    Thanks Abhijit, that function seems to do the job, I also found this link which had sample code:

    http://delphi.newswhat.com/geoxml/forumhistorythread?groupname=borland.public.delphi.nativeapi.win32&messageid=40914cf6@newsgroups.borland.com

    unit GetGroupsForUserUnit;  interface  uses   Windows, SysUtils, Classes, ShellAPI;  type   {$EXTERNALSYM NET_API_STATUS}   NET_API_STATUS = DWORD;   LPLOCALGROUP_USERS_INFO_0 = ^LOCALGROUP_USERS_INFO_0;   {$EXTERNALSYM LPLOCALGROUP_USERS_INFO_0}   PLOCALGROUP_USERS_INFO_0 = ^LOCALGROUP_USERS_INFO_0;   {$EXTERNALSYM PLOCALGROUP_USERS_INFO_0}   _LOCALGROUP_USERS_INFO_0 = record     lgrui0_name: LPWSTR;   end;   {$EXTERNALSYM _LOCALGROUP_USERS_INFO_0}   LOCALGROUP_USERS_INFO_0 = _LOCALGROUP_USERS_INFO_0;   {$EXTERNALSYM LOCALGROUP_USERS_INFO_0}   TLocalGroupUsersInfo0 = LOCALGROUP_USERS_INFO_0;   PLocalGroupUsersInfo0 = PLOCALGROUP_USERS_INFO_0;  const   {$EXTERNALSYM MAX_PREFERRED_LENGTH}     MAX_PREFERRED_LENGTH = DWORD(-1);   {$EXTERNALSYM NERR_Success}     NERR_Success = 0;   {$EXTERNALSYM NERR_BASE}     NERR_BASE = 2100;   {$EXTERNALSYM NERR_UserNotFound}     NERR_UserNotFound = (NERR_BASE+121);   {$EXTERNALSYM NERR_InvalidComputer}     NERR_InvalidComputer = (NERR_BASE+251);   {$EXTERNALSYM LG_INCLUDE_INDIRECT}     LG_INCLUDE_INDIRECT = $0001;   {$EXTERNALSYM NetUserGetLocalGroups} function NetUserGetLocalGroups(servername: PWideChar; username: PWideChar;   level: DWORD; flags: DWORD; var bufptr: Pointer; prefmaxlen: DWORD;   var entriesread: DWORD; var totalentries: DWORD): NET_API_STATUS; stdcall; {$EXTERNALSYM NetApiBufferFree} function NetApiBufferFree(Buffer: Pointer): NET_API_STATUS; stdcall;  function GetGroupsForNetUser(uname: widestring): string;  implementation  function NetUserGetLocalGroups; external 'netapi32.dll' name 'NetUserGetLocalGroups'; function NetApiBufferFree; external 'netapi32.dll' name 'NetApiBufferFree';  function GetGroupsForNetUser(uname: widestring): string; // NetUserGetLocalGroups - returns semi-colon delim string of groups. // Pass in user value returned by GetUserName to get current user. var   bufptr: Pointer;   Status: NET_API_STATUS;   PrefMaxLen, EntriesRead, TotalEntries: DWord;   i: integer;   pTmpBuf: LPLOCALGROUP_USERS_INFO_0; begin   PrefMaxLen := MAX_PREFERRED_LENGTH;   Status := NetUserGetLocalGroups(nil, PWideChar(uname), 0 ,         LG_INCLUDE_INDIRECT, bufptr, PrefMaxLen,         EntriesRead, TotalEntries);   case Status of     NERR_Success: begin       result := 'success, but no groups';       pTmpBuf := bufptr;       if pTmpBuf <> nil then         begin         result := '';         for i := 0 to EntriesRead - 1 do         begin           if pTmpBuf <> nil then           begin             if result = '' then             begin               result := pTmpBuf.lgrui0_name             else               result := result + ';' + pTmpBuf.lgrui0_name;           end;           Inc(pTmpBuf);         end;       end;     end;     ERROR_ACCESS_DENIED: begin       result := 'The user does not have access.';     end;     NERR_InvalidComputer: begin       result := 'The computer name is invalid.';     end;     NERR_UserNotFound: begin       result := 'The user name could not be found. (' + uname + ')';     end;     else begin       result := 'Unknown error.';     end;   end;    if bufptr <> nil then           NetApiBufferFree(bufptr); end;  end. 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 250k
  • Answers 250k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are two options... with slightly surprising performance: Redundant checking:… May 13, 2026 at 9:19 am
  • Editorial Team
    Editorial Team added an answer The code calling your function is not providing a defined… May 13, 2026 at 9:19 am
  • Editorial Team
    Editorial Team added an answer Try using the more concise #reject! syntax, since the #delete… May 13, 2026 at 9:19 am

Related Questions

I have a bit of code for a dll that is needed by two
Say I have a third party Application that does background work, but prints out
Note: Currently using Perforce as a CM tool. I currently do several debug releases
I need a version control system that works like Subversion but is able to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.