开发者

Error Could not load file or assembly 'Interop.ActiveDs'

I'm doing some active directory work with c# and I'm getting this error on my page

System.IO.FileNotFoundException: Could not load file or assembly 'Interop.ActiveDs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=46db4b78e98e1c9d' or one of its dependencies. The system cannot find the file specified.

It's having some issue with the ActiveDS reference that was added I'm on a 64-bit machine and the server it runs on is also x64

I added the ActiveDS reference so I could do something like this

newRoleGroup.Properties["group开发者_C百科Type"].Value = ActiveDs.ADS_GROUP_TYPE_ENUM.ADS_GROUP_TYPE_UNIVERSAL_GROUP;

So my question is, why can't it load the ActiveDs reference?


Try this:

1) Copy the C:\Windows\SysWOW64\ActiveDs.dll and its respective ActiveDs.tlb file to a folder within your solution; call it an External Reference folder

2) Remove the reference to ActiveDs in your project

3) Add a new reference, but this time instead of picking the COM version, pick the TLB instead. Visual Studio will create the Intero wrapper for you.


You'd be far better off not taking the reference to the COM library and instead just declaring the proper constants in your code e.g.:

enum  ADS_GROUP_TYPE_ENUM {
  public long ADS_GROUP_TYPE_GLOBAL_GROUP = 0x00000002,
  public long ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP   = 0x00000004,
  public long ADS_GROUP_TYPE_LOCAL_GROUP          = 0x00000004,
  public long ADS_GROUP_TYPE_UNIVERSAL_GROUP      = 0x00000008,
  public long ADS_GROUP_TYPE_SECURITY_ENABLED     = 0x80000000
}


I created an enum similar to Brian Desmond's answer:

private enum GroupType : uint
{
    UniversalGroup = 0x8,
    DomainLocalGroup = 0x4,
    GlobalGroup = 0x2,
    SecurityGroup = 0x80000000
}

and checked for both the universal group and security group like this:

private const int UniversalSecurityGroup = unchecked((int)(GroupType.UniversalGroup | GroupType.SecurityGroup));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜