N
news.microsoft.com
Hi,
Anyone there who can give me a jump start for retrieving the groups a user
belongs to???
Since now i tried this but keeps on giving an error on line
(listBox1.Items.Add("Groups to which {0} belongs:"+ oUser.Name);
The oUser object is returning an error " AdsObject <error: an exception of
type: {System.Runtime.InteropServices.COMException} occurred>
System.DirectoryServices.Interop.UnsafeNativeMethods.IAds
"
string strUserADsPath = "LDAP://" + System.Environment.UserDomainName +
"/CN=" + textBox1.Text +",CN=users,DC=" + System.Environment.UserDomainName
+
",DC=nl";
DirectoryEntry oUser;
oUser = new DirectoryEntry(strUserADsPath);
listBox1.Items.Add("Groups to which {0} belongs:"+ oUser.Name);
// Invoke IADsUser::Groups method.
object groups = oUser.Invoke("Groups");
foreach ( object group in (IEnumerable)groups)
{
// Get the Directory Entry.
DirectoryEntry groupEntry = new DirectoryEntry(group);
listBox1.Items.Add(groupEntry.Name);
Please help me on thisone.
Regards.
Rene
Anyone there who can give me a jump start for retrieving the groups a user
belongs to???
Since now i tried this but keeps on giving an error on line
(listBox1.Items.Add("Groups to which {0} belongs:"+ oUser.Name);
The oUser object is returning an error " AdsObject <error: an exception of
type: {System.Runtime.InteropServices.COMException} occurred>
System.DirectoryServices.Interop.UnsafeNativeMethods.IAds
"
string strUserADsPath = "LDAP://" + System.Environment.UserDomainName +
"/CN=" + textBox1.Text +",CN=users,DC=" + System.Environment.UserDomainName
+
",DC=nl";
DirectoryEntry oUser;
oUser = new DirectoryEntry(strUserADsPath);
listBox1.Items.Add("Groups to which {0} belongs:"+ oUser.Name);
// Invoke IADsUser::Groups method.
object groups = oUser.Invoke("Groups");
foreach ( object group in (IEnumerable)groups)
{
// Get the Directory Entry.
DirectoryEntry groupEntry = new DirectoryEntry(group);
listBox1.Items.Add(groupEntry.Name);
Please help me on thisone.
Regards.
Rene