|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
User Groupsthe examples I come across don't work. I'm unsure as to whether it is due to permissions on our network or if I'm constructing the path to use incorrectly. Below is C# code I found that should list the groups for a given user, I've ommitted the actual values for my network for obvious reasons, instead I've used a domain which would be abc.def.net as the domain I am accessing. Any help on either why this is not working or examples that I can use would be great. Nathan string strUserADsPath = "LDAP://abc.def.net/cn=" +textBox1.Text +",cn=users,dc=abc,dc=def,dc=net"; 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); } That approach won't get you all the groups for the user (nested membership
and primary group will be excluded), but it should work. What error are you getting (full stace trace)? Joe K. Show quoteHide quote "Nathan" <Nat***@discussions.microsoft.com> wrote in message news:965A5908-E59E-493A-8FDB-4B903DDCC67C@microsoft.com... >I am attempting for find the groups that a user is associated with but all > the examples I come across don't work. I'm unsure as to whether it is due > to > permissions on our network or if I'm constructing the path to use > incorrectly. > > Below is C# code I found that should list the groups for a given user, > I've > ommitted the actual values for my network for obvious reasons, instead > I've > used a domain which would be abc.def.net as the domain I am accessing. > > Any help on either why this is not working or examples that I can use > would > be great. > > Nathan > > string strUserADsPath = "LDAP://abc.def.net/cn=" +textBox1.Text > +",cn=users,dc=abc,dc=def,dc=net"; > 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); > } The error occurs on the line listBox1.Items.Add("Groups to which {0}
belongs:"+ oUser.Name); Stack trace is as follows "System.Runtime.InteropServices.COMException (0x80072030): There is no such object on the server at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_Name() at Groups.Form1.button1_Click(Object sender, EventArgs e) in c:\\dev\\visual studio projects\\groups\\form1.cs:line 135" I know our domain is ActiveDirectory as our existing VB6 app uses similar code to retrieve users groups, what COM object is it trying to get? Show quoteHide quote "Joe Kaplan (MVP - ADSI)" wrote: > That approach won't get you all the groups for the user (nested membership > and primary group will be excluded), but it should work. What error are you > getting (full stace trace)? > > Joe K. > > "Nathan" <Nat***@discussions.microsoft.com> wrote in message > news:965A5908-E59E-493A-8FDB-4B903DDCC67C@microsoft.com... > >I am attempting for find the groups that a user is associated with but all > > the examples I come across don't work. I'm unsure as to whether it is due > > to > > permissions on our network or if I'm constructing the path to use > > incorrectly. > > > > Below is C# code I found that should list the groups for a given user, > > I've > > ommitted the actual values for my network for obvious reasons, instead > > I've > > used a domain which would be abc.def.net as the domain I am accessing. > > > > Any help on either why this is not working or examples that I can use > > would > > be great. > > > > Nathan > > > > string strUserADsPath = "LDAP://abc.def.net/cn=" +textBox1.Text > > +",cn=users,dc=abc,dc=def,dc=net"; > > 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); > > } > > > You usually get that error when the DN (the part after the DNS name) you
specified doesn't point to a real object. Are you sure the DN in your path is correct? Joe K. Show quoteHide quote "Nathan" <Nat***@discussions.microsoft.com> wrote in message news:37546518-03D5-470B-8E9F-292E06BBE7A6@microsoft.com... > The error occurs on the line listBox1.Items.Add("Groups to which {0} > belongs:"+ oUser.Name); > > Stack trace is as follows > > "System.Runtime.InteropServices.COMException (0x80072030): There is no > such > object on the server > at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) > at System.DirectoryServices.DirectoryEntry.Bind() > at System.DirectoryServices.DirectoryEntry.get_Name() > at Groups.Form1.button1_Click(Object sender, EventArgs e) in > c:\\dev\\visual studio projects\\groups\\form1.cs:line 135" > > I know our domain is ActiveDirectory as our existing VB6 app uses similar > code to retrieve users groups, what COM object is it trying to get? > > > "Joe Kaplan (MVP - ADSI)" wrote: > >> That approach won't get you all the groups for the user (nested >> membership >> and primary group will be excluded), but it should work. What error are >> you >> getting (full stace trace)? >> >> Joe K. >> >> "Nathan" <Nat***@discussions.microsoft.com> wrote in message >> news:965A5908-E59E-493A-8FDB-4B903DDCC67C@microsoft.com... >> >I am attempting for find the groups that a user is associated with but >> >all >> > the examples I come across don't work. I'm unsure as to whether it is >> > due >> > to >> > permissions on our network or if I'm constructing the path to use >> > incorrectly. >> > >> > Below is C# code I found that should list the groups for a given user, >> > I've >> > ommitted the actual values for my network for obvious reasons, instead >> > I've >> > used a domain which would be abc.def.net as the domain I am accessing. >> > >> > Any help on either why this is not working or examples that I can use >> > would >> > be great. >> > >> > Nathan >> > >> > string strUserADsPath = "LDAP://abc.def.net/cn=" +textBox1.Text >> > +",cn=users,dc=abc,dc=def,dc=net"; >> > 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); >> > } >> >> >> Joe, sorry to sound thick but which part of the string is the DNS name?
Show quoteHide quote "Joe Kaplan (MVP - ADSI)" wrote: > You usually get that error when the DN (the part after the DNS name) you > specified doesn't point to a real object. Are you sure the DN in your path > is correct? > > Joe K. > > "Nathan" <Nat***@discussions.microsoft.com> wrote in message > news:37546518-03D5-470B-8E9F-292E06BBE7A6@microsoft.com... > > The error occurs on the line listBox1.Items.Add("Groups to which {0} > > belongs:"+ oUser.Name); > > > > Stack trace is as follows > > > > "System.Runtime.InteropServices.COMException (0x80072030): There is no > > such > > object on the server > > at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) > > at System.DirectoryServices.DirectoryEntry.Bind() > > at System.DirectoryServices.DirectoryEntry.get_Name() > > at Groups.Form1.button1_Click(Object sender, EventArgs e) in > > c:\\dev\\visual studio projects\\groups\\form1.cs:line 135" > > > > I know our domain is ActiveDirectory as our existing VB6 app uses similar > > code to retrieve users groups, what COM object is it trying to get? > > > > > > "Joe Kaplan (MVP - ADSI)" wrote: > > > >> That approach won't get you all the groups for the user (nested > >> membership > >> and primary group will be excluded), but it should work. What error are > >> you > >> getting (full stace trace)? > >> > >> Joe K. > >> > >> "Nathan" <Nat***@discussions.microsoft.com> wrote in message > >> news:965A5908-E59E-493A-8FDB-4B903DDCC67C@microsoft.com... > >> >I am attempting for find the groups that a user is associated with but > >> >all > >> > the examples I come across don't work. I'm unsure as to whether it is > >> > due > >> > to > >> > permissions on our network or if I'm constructing the path to use > >> > incorrectly. > >> > > >> > Below is C# code I found that should list the groups for a given user, > >> > I've > >> > ommitted the actual values for my network for obvious reasons, instead > >> > I've > >> > used a domain which would be abc.def.net as the domain I am accessing. > >> > > >> > Any help on either why this is not working or examples that I can use > >> > would > >> > be great. > >> > > >> > Nathan > >> > > >> > string strUserADsPath = "LDAP://abc.def.net/cn=" +textBox1.Text > >> > +",cn=users,dc=abc,dc=def,dc=net"; > >> > 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); > >> > } > >> > >> > >> > > > The ADS Path is basically:
<scheme>://<server>/<object> scheme is LDAP or GC for LDAP databases. Server is optional for AD and can be lots of things like the DNS name of a DC, the DNS name of a domain, an IP address or a netbios name (or blank if doing serverless binding, which finds a DC based on the current thread's security context's domain membership). It can also contain a port if the default port is not right. The object part is an LDAP distinguished name or other special identifier known by the directory. If it is null, it tries to find the defaultNamingContext. HTH, Joe K. Show quoteHide quote "Nathan" <Nat***@discussions.microsoft.com> wrote in message news:E96C3D8B-85E1-4553-9631-55FD9AAD4C78@microsoft.com... > Joe, sorry to sound thick but which part of the string is the DNS name? > > "Joe Kaplan (MVP - ADSI)" wrote: > >> You usually get that error when the DN (the part after the DNS name) you >> specified doesn't point to a real object. Are you sure the DN in your >> path >> is correct? >> >> Joe K. >> >> "Nathan" <Nat***@discussions.microsoft.com> wrote in message >> news:37546518-03D5-470B-8E9F-292E06BBE7A6@microsoft.com... >> > The error occurs on the line listBox1.Items.Add("Groups to which {0} >> > belongs:"+ oUser.Name); >> > >> > Stack trace is as follows >> > >> > "System.Runtime.InteropServices.COMException (0x80072030): There is no >> > such >> > object on the server >> > at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) >> > at System.DirectoryServices.DirectoryEntry.Bind() >> > at System.DirectoryServices.DirectoryEntry.get_Name() >> > at Groups.Form1.button1_Click(Object sender, EventArgs e) in >> > c:\\dev\\visual studio projects\\groups\\form1.cs:line 135" >> > >> > I know our domain is ActiveDirectory as our existing VB6 app uses >> > similar >> > code to retrieve users groups, what COM object is it trying to get? >> > >> > >> > "Joe Kaplan (MVP - ADSI)" wrote: >> > >> >> That approach won't get you all the groups for the user (nested >> >> membership >> >> and primary group will be excluded), but it should work. What error >> >> are >> >> you >> >> getting (full stace trace)? >> >> >> >> Joe K. >> >> >> >> "Nathan" <Nat***@discussions.microsoft.com> wrote in message >> >> news:965A5908-E59E-493A-8FDB-4B903DDCC67C@microsoft.com... >> >> >I am attempting for find the groups that a user is associated with >> >> >but >> >> >all >> >> > the examples I come across don't work. I'm unsure as to whether it >> >> > is >> >> > due >> >> > to >> >> > permissions on our network or if I'm constructing the path to use >> >> > incorrectly. >> >> > >> >> > Below is C# code I found that should list the groups for a given >> >> > user, >> >> > I've >> >> > ommitted the actual values for my network for obvious reasons, >> >> > instead >> >> > I've >> >> > used a domain which would be abc.def.net as the domain I am >> >> > accessing. >> >> > >> >> > Any help on either why this is not working or examples that I can >> >> > use >> >> > would >> >> > be great. >> >> > >> >> > Nathan >> >> > >> >> > string strUserADsPath = "LDAP://abc.def.net/cn=" +textBox1.Text >> >> > +",cn=users,dc=abc,dc=def,dc=net"; >> >> > 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); >> >> > } >> >> >> >> >> >> >> >> >>
error passing byte[] of encrypted data to Web Service
sslstream and certificates Impersonation through HttpModule CAPICOM problem:cannot access certificate store IIS / SQL Server impersonation web application development user rights req .Net Authorization and NTFS permissions Protect source DPAPI HKEY_USERS, what is it for? |
|||||||||||||||||||||||