I am trying to get all users by group name and dispalay it in sharepoint webpart. adGroupName something like = \"CompanyGroup\".
GroupPrincipal grp = GroupPr
Do you use something like this to get your context ?
/* Retreiving a principal context
*/
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "MachineIP:389", "dc=dom,dc=fr", "jpb", "root.123");
Where you can replace MachineIP by the DNS name of your domain or one of you DC.
Answer was found in blog:
http://sharepoint-tweaking.blogspot.com/2007/12/impersonation-in-aspnet-causes.html
Solution is to use code:
using (HostingEnvironment.Impersonate()) {
// This code runs as the application pool user
DirectorySearcher searcher ...
}