ADSI in NT40

P

powerranger

I'm new with ADSI with .Net. I'm developing a windows application to
get the NT group name based on the user id. The application installed
successfully on the target computer (OS NT with the latest patch and
DSclient). Here is the code:

int idx = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString().IndexOf("\\");
string gusernm = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Substring(idx
+ 1);

// WinNT provider - domain name
string domainPath = "WinNT://MYDOMAIN/";

DirectoryEntry groupEntry = new DirectoryEntry( domainPath + gusernm
,gusernm, "", authenticationTypes.Secure);

System.DirectoryServices.PropertyCollection pcoll =
groupEntry.Properties;

// Invoke Groups method.
object obGroups = groupEntry.Invoke("Groups");

// Create object for each group.
DirectoryEntry obGpEntry;

try
{
foreach (object ob in (IEnumerable)obGroups)
{
obGpEntry = new DirectoryEntry(ob);
MessageBox.Show(obGpEntry.Name, "Info", MessageBoxButtons.OK);
}
}
catch (Exception ex)
{
MessageBox.Show("error " + ex.ToString(), "Warning",
MessageBoxButtons.OK);
}

If I run the application on Windows 2K, it runs without any error.
But on NT40,
I gives an error. Can someone help me to solve this problem? Any
sample of code is helpful. Thanks much!!
 
M

Marc Scheuner [MVP ADSI]

If I run the application on Windows 2K, it runs without any error.
But on NT40, I gives an error.

WHAT error does it give? WHERE does that error occur in your code?

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top