problem getting User Group Memebership in Active Directory

  • Thread starter Patrick Olurotimi Ige
  • Start date
P

Patrick Olurotimi Ige

I have a .aspx page that gets USERS GROUPS from the Active Directory
after inputing the USERNAME of the user in a textbox.

And this has been working for me.
But now i get the error:-

"An Error occurred while getting group memberships
The referenced account is currently locked out and may not be logged on
to"

An ideas what is wrong?
 
J

Joe Kaplan \(MVP - ADSI\)

It sounds like the referenced account may be locked. If you can show a
short code sample that demonstrates this problem, that would be helpful.

Joe K.
 
P

Patrick Olurotimi Ige

Joe thanks for the reply but 'm getting the error when i try
retrieving the GroupMemberships.
Patrick


private string[] GetGroupMemberships(string path, ref int
primaryGroupID)
{
StringBuilder groupNames = new StringBuilder();
try
{
DirectoryEntry entry = new DirectoryEntry(path);

string[] properties = {"memberof", "primarygroupid"};

entry.RefreshCache(properties);

// invoke Groups method which will get all groups
// user is member of even primary group

object groups = entry.Invoke("Groups");

// the read group name from collection
foreach (object group in (IEnumerable)groups)
{
DirectoryEntry groupEntry = new DirectoryEntry(group);
groupNames.Append(groupEntry.Name);
groupNames.Append("|");
groupEntry.Dispose();
}

// set primary group id
primaryGroupID =
Convert.ToInt32(entry.Properties["primarygroupid"].Value);
entry.Dispose();
}
catch (Exception ex)
{
Response.Write("<font color=red>An Error occurred while
getting group memberships. " +
ex.Message + "</font>");
Response.End();
}
return groupNames.ToString().TrimEnd(new char[]{'|'}).Split(new
char[]{'|'});
}
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top