GroupPrincipal method FindByIdentity throw strange exception

前端 未结 2 1939
离开以前
离开以前 2021-01-14 07:28

I am trying to get all users by group name and dispalay it in sharepoint webpart. adGroupName something like = \"CompanyGroup\".

GroupPrincipal grp = GroupPr         


        
相关标签:
2条回答
  • 2021-01-14 08:07

    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.

    0 讨论(0)
  • 2021-01-14 08:19

    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 ...
    }
    
    0 讨论(0)
提交回复
热议问题