tags:

views:

56

answers:

1

Hi,

I am new to JNA, I want to convert DsGetDcName method to JNA.

DWORD DsGetDcName(
  __in   LPCTSTR ComputerName,
  __in   LPCTSTR DomainName,
  __in   GUID *DomainGuid,
  __in   LPCTSTR SiteName,
  __in   ULONG Flags,
  __out  PDOMAIN_CONTROLLER_INFO *DomainControllerInfo
);

I have converted the above function to JNA I replaced above parameters as follows

public static class GUID extends Structure {
    public int Data1;
    public short  Data2;
    public short  Data3;
    public byte  Data4[]= new byte[8];
}

public static class DOMAIN_CONTROLLER_INFO extends Structure { 
    public String DomainControllerName;
    public String DomainControllerAddress;
    public int DomainControllerAddressType;
    public GUID DomainGuid; // created Structure above
    public String DomainName;
    public String DnsForestName;
    public int Flags;
    public String DcSiteName;
    public String ClientSiteName;
}

int DsGetDCName(
    String strComputerName,
    String strDomainName,
    GUID DomainGuid, // static class created extending with structure
    String strSiteName,
    int iFlags,
    DOMAIN_CONTROLLER_INFO  DomainControllerInfo // static class created extending with structure
);

The above function returns 997 Error (ERROR IO PENDING). The method declaration is correct. Can any help on this issue? Thanks in Advance.

Regards

Pavan Kumar A.

+1  A: 

This is implemented in JNA 3.2.7 as com.sun.jna.platform.win32.Netapi32.DsGetDcName. Use Netapi32Util.DsGetDcName which is a simplified wrapper.

dblock