473,321 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Group Listing problem

Hello group,

Trying to get a list of groups, including nested groups, for an account.
Anyone see any problem with this code? It is returing a LOT of 122
ERROR_INSUFFICIENT_BUFFER errors.

ArrayList alGroups = new ArrayList();
int bufferSize = 1024;
int groupLength = bufferSize;
int domainLength = bufferSize;
int sidNameUse= 0;
int errorReturn;
StringBuilder group;
StringBuilder domain;
string[] props = {"tokenGroups"};

_de.RefreshCache(props);

foreach(byte[] sid in _de.Properties["tokenGroups"])
{
IntPtr sidPtr = Marshal.AllocHGlobal(sid.Length);
Marshal.Copy(sid, 0, sidPtr, sid.Length);
group = new StringBuilder(bufferSize);
domain = new StringBuilder(bufferSize);

errorReturn = LookupAccountSid(null, sidPtr, group, ref groupLength,
domain, ref domainLength, out sidNameUse);

if(errorReturn == 0)
group = new StringBuilder("Error: " + Marshal.GetLastWin32Error());

alGroups.Add(group);

Marshal.FreeHGlobal(sidPtr);
}

_groups = alGroups;
I have tried multiple buffer lengths... nothing seems to work. I am also
getting a ERROR_NONE_MAPPED error once as well.

TIA,
Jason S.
Nov 15 '05 #1
1 1256
Ok, found a later post by Willy that cleared it up. Evidently you need to
call LookupAccountSid twice each time... once to prime the buffers and then
again to get the info.

Still getting the ERROR_NONE_MAPPED error tho....

Jason S.

"Jason S" <so*****@somewhere.com> wrote in message
news:OP**************@tk2msftngp13.phx.gbl...
Hello group,

Trying to get a list of groups, including nested groups, for an account.
Anyone see any problem with this code? It is returing a LOT of 122
ERROR_INSUFFICIENT_BUFFER errors.

ArrayList alGroups = new ArrayList();
int bufferSize = 1024;
int groupLength = bufferSize;
int domainLength = bufferSize;
int sidNameUse= 0;
int errorReturn;
StringBuilder group;
StringBuilder domain;
string[] props = {"tokenGroups"};

_de.RefreshCache(props);

foreach(byte[] sid in _de.Properties["tokenGroups"])
{
IntPtr sidPtr = Marshal.AllocHGlobal(sid.Length);
Marshal.Copy(sid, 0, sidPtr, sid.Length);
group = new StringBuilder(bufferSize);
domain = new StringBuilder(bufferSize);

errorReturn = LookupAccountSid(null, sidPtr, group, ref groupLength,
domain, ref domainLength, out sidNameUse);

if(errorReturn == 0)
group = new StringBuilder("Error: " + Marshal.GetLastWin32Error());

alGroups.Add(group);

Marshal.FreeHGlobal(sidPtr);
}

_groups = alGroups;
I have tried multiple buffer lengths... nothing seems to work. I am also
getting a ERROR_NONE_MAPPED error once as well.

TIA,
Jason S.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris | last post by:
Hello Am really worried, so wondered if anyone could help. My site outgrew itself recently so we've had to make changes to the url structure. I have some important url's like this:...
10
by: Chris | last post by:
Hi, Not sure if this is the right forum, but hopefully someone can help me. I am creating something for our intranet and i want to list the files and folders of a directory, i found some code...
19
by: SU News Server | last post by:
I've struggled with this for quite a while and I'm am just not sure what is going on. I have the following code import os def buildList( directory='/Users/mkonrad' ) dirs = listing =...
3
by: David Jacques | last post by:
I am trying to get a list of all files of a certain extension type on disk to do some processing in a loop. The code needs to be portable to UNIX, so I need to use plain c functionality. Does...
8
by: tlyczko | last post by:
I am developing an Access database that will be used by some users logging into Citrix servers. Using the "Code 1" listing, 'fGetFullNameOfLoggedUser' from Dev Ashish's site, which I found in...
1
by: Johnny Jörgensen | last post by:
I've got a serious problem. I've got Visual Studio 2005 installed, and of course I'm using the Pretty Listing formatting function. When I start up VS, everything is fine, but after a while (which...
0
by: Phylum | last post by:
Hi all. Just signed up today and I was hoping to simplify a task I'm sure we may all benefit from. I thank you in advance for clicking on this post! I want to warn you that I'm no coding guru - I...
6
by: John Crane | last post by:
Anybody know if they exist on the net? I tried the hal9k link which took me to planetmirror which hangs when I try to download anything from it. -John
0
by: jatuphum | last post by:
Hi all, I have xml like these below. <Listing> <Avail> <Field1>aaa</Field1> <Field2>800</Field2> <Field3>900</Field3> <SortValue>20.00</SortValue>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.