Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "AI" in [All]

ntdsapi

.
Summary
The DsBindWithCred function binds to a domain controller using the specified credentials.
.

    [MarshalAs(UnmanagedType.LPWStr)] String DomainControllerName,

.

    [MarshalAs(UnmanagedType.LPWStr)] String DnsDomainName,

.
Summary
The DsBindWithCred function binds to a domain controller using the specified credentials.
.

    [MarshalAs(UnmanagedType.LPWStr)] String DomainControllerName,

.

    [MarshalAs(UnmanagedType.LPWStr)] String DnsDomainName,

.
Summary
The DsCrackNames function converts an array of directory service object names from one format to another. Name conversion enables client applications to map between the multiple names used to identify various directory service objects. For example, user objects can be identified by SAM account names (domain\username), user principal name (username@domain.com), or distinguished name.
.

The success of the name conversion request depends on where the client is bound. Clients bind to specific instances of the directory service using some variant of DsBind. If bound to a global catalog, the scope of the name mapping is the entire forest. If not bound to a global catalog, the scope of the name mapping is the domain not covered by a global catalog for that domain controller. If not bound to a global catalog and a name is not found, but the input name unambiguously identifies its domain and this domain is in the forest, then the return data identifies the DNS domain name for the domain of interest. Clients are expected to use this data to bind to the correct domain controller or global catalog and call DsCrackNames again with the new bind handle.

.

using System.Runtime.ConstrainedExecution;

.

      // domain object resides in.  Thus DS_NAME_RESULT_ITEM?.pDomain

.

      DS_NAME_ERROR_DOMAIN_ONLY = 5,

.

      // The call fails if the DC is not a GC

.

      // Domain-only version includes trailing '\\'.

.

      // DS_DOMAIN_SIMPLE_NAME = 4,

.

      // Domain-only version includes trailing '/'.

.

      // replaced with '\n' - even in domain-only case.

.

      // Pseudo-name format so GetUserNameEx can return the DNS domain name to

.

      DS_DNS_DOMAIN_NAME = 12

.

      public DsHandle(string domainControllerName = null, string dnsDomainName = null)

.

         uint res = DsBind(domainControllerName, dnsDomainName, out handle);

.

      string DomainControllerName, // in, optional

.

      string DnsDomainName, // in, optional

.

      public string pDomain;

.
Summary
The DsGetDomainControllerInfo function retrieves data about the domain controllers in a domain (see DS_DOMAIN_CONTROLLER_INFO_2 structure)
.

public static extern uint DsGetDomainControllerInfo(

.

     string DomainName,

.

pInf is an array of DS_DOMAIN_CONTROLLER_INFO_1 or DS_DOMAIN_CONTROLLER_INFO_2 dependent on InfoLevel

.

Returned DS_DOMAIN_CONTROLLER_INFO_x[] must be freed by calling DsFreeDomainControllerInfo(...).

.

        string DomainControllerName,

.

        string DnsDomainName, out IntPtr phDS

.

    public struct DS_DOMAIN_CONTROLLER_INFO_2

.

        public string ComputerObjectName;     // CN=SDBAD10004,OU=Domain Controllers,DC=dom1,DC=ad,DC=sys

.

    public static extern uint DsGetDomainControllerInfo(

.

        string DomainName,

.

    public static extern void DsFreeDomainControllerInfo(

.

    static void Main(string[] args)

.

        Console.WriteLine("binding to domain controllert");

.

        NtdsHelper.DS_DOMAIN_CONTROLLER_INFO_2[] DCinfos;

.

        IntPtr pDCinfos; // pointer to array of DS_DOMAIN_CONTROLLER_INFO_2

.

        ret = NtdsHelper.DsGetDomainControllerInfo(hDC, "dom1.ad.sys", 2, out nInfo, out pDCinfos);

.

            DCinfos = new NtdsHelper.DS_DOMAIN_CONTROLLER_INFO_2[nInfo];

.

            NtdsHelper.DS_DOMAIN_CONTROLLER_INFO_2 OneInfo;

.

                OneInfo = (NtdsHelper.DS_DOMAIN_CONTROLLER_INFO_2)Marshal.PtrToStructure(

.

                typeof(NtdsHelper.DS_DOMAIN_CONTROLLER_INFO_2)

.

                 Marshal.SizeOf(typeof(NtdsHelper.DS_DOMAIN_CONTROLLER_INFO_2)));

.

            NtdsHelper.DsFreeDomainControllerInfo(2, nInfo, pDCinfos);

.

            Console.WriteLine("error getting domain infos");

.

     [MarshalAs(UnmanagedType.LPWStr)] String Domain,

.

    static void Main(string[] args)

.

        string domainController = "domaincontroller.contoso.com";

.

        string domain = "contoso.com";

.

        result = DsBind(domainController, domain, out phDS);

.

        Console.WriteLine("Couldn't bind to the domain {0} on domain controller {1}.", domain, domainController);

.

      string DomainControllerName,

.

      string DnsDomainName,

.
Summary
The DsUnBind function finds an RPC session with a domain controller and unbinds a handle to the directory service (DS).
.
Import
credui,advapi32,gdi32,kernel32,ole32,shell32,user32,glossary,coredll,rasapi32,mpr,netapi32,uxtheme,avifil32,aygshell,winscard,crypt32,secur32,wtsapi32,shlwapi,winspool,oleacc,rapi,oleaut32,winfax,odbc32,msi,cards,powrprof,urlmon,xolehlp,twain_32,winmm,wininet,comdlg32,imm32,Constants,Delegates,Enums,Interfaces,Structures

winspool

.

    MessageBox.Show(String.Format("Adding the monitor failed.\n\nError: {0}", errorMessage), sErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);

.

    MessageBox.Show(String.Format("Adding the monitor failed:\n\nException: {0}", e.ToString()), sErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);

.

     MessageBox.Show(String.Format("Deleting the monitor failed.\n\nError: {0}", errorMessage), sErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);

.

   MessageBox.Show(String.Format("Deleting the monitor failed.\n\nException: {0}", ex.ToString()), sErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);

.

Obtain a pointer to the DEVMODE struct (either printerHandle or printerName can be NULL | IntPtr.ZERO):

.

On a Win8 x64 system, I encountered the issue when I was trying to target x86 compiling. The call to DocumentProperties would fail and return -1 for sizeNeeded.

.

If I target x64 or AnyCPU, everything is working fine. However, because of other constraints, I had to target x86 and couldn't make it work without using the IntPtr.Zero fix. Now it works in every configuration.

.

    /// structure contains printer driver information

.

        /// Pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains the device driver (for example, C:\DRIVERS\Pscript.dll).

.

        /// Pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains driver data (for example, C:\DRIVERS\Qms810.ppd).

.

        /// A pointer to a MultiSZ buffer that contains a sequence of null-terminated strings. Each null-terminated string in the buffer contains the name of a file the driver depends on. The sequence of strings is terminated by an empty, zero-length string. If pDependentFiles is not NULL and does not contain any file names, it will point to a buffer that contains two empty strings.

.
Summary
Contains printer driver information.
.

    'this call will always fail (return non-0)

.

        throw new Exception("EnumMonitors should fail!");

.
Summary
Enum all Available Ports in a System.
.

        throw new Exception("EnumPorts should fail!");

.

        'to zero. The call will fails specifying

.

        throw new Exception("EnumPrinters should fail!");

.

    // length contains the path length

.

    // str contains the path

.

Hey Marty, I'm not your answering service, but you're outside pouting about the car, Jennifer Parker called you twice. Say that again. Calvin, why do you keep calling me Calvin? Marty, you didn't fall asleep, did you? I'm too loud. I can't believe it. I'm never gonna get a chance to play in front of anybody.

.

As always, only do SetLastError=true if you actually intend to call GetLastError (This includes throwing a Win32Exception if the call fails)

21: SetJob
.

    Public Const JOB_CONTROL_RETAIN = &H8

.

    // Returns true on success, false on failure.

.

    bool    bSuccess = false; // Assume failure unless you specifically succeed.

.

        // hXvc contains an Xcv data handle to a local TCPMON port

glossary

.

Written by Gabriel Sharp, Dec 2005-Jan 2007 AI Productions

.
Summary
LibHolocaust, System.AIPCC.Pinvoke (new to LH ver 1.0.3.9b, replaces System.AIPCC.WindowsAPI in older versions)
.

     AI Productions - A Collection of pinvoke and framework simplification extensions (aka FSE) is free to download

.

    Namespaces: System.AIPCC.Pinvoke.Functions (seperated further by libname, wont list it here though)

.

           System.AIPCC.Pinvoke.Structures

.

           System.AIPCC.Pinvoke.Enums

.

           System.AIPCC.Pinvoke.Constants

.

           System.AIPCC.Pinvoke.Callbacks (delegates)

.

     Namespaces: System.AIPCC.Pinvoke.COM.UUID

.

             System.AIPCC.Pinvoke.COM.Interfaces

.

             System.AIPCC.Pinvoke.COM.Classes

.

             System.AIPCC.Pinvoke.COM       <- contains base functions such as CoInitialize()

.

Download Mirror Link (US/East): [ http://mysite.verizon.net/aiproductions ]

.

          Library: AIPCC-Pinvoke.dll

.

Marvelous rivetting stuff bent as a nine bob note taking the mick owt terribly Sonic Screwdriver, it's me peepers a bit wonky jolly hockey sticks the fuzz on his bill. Cor blimey' naff one would like curry sauce lost her marbles bloody shambles down South what a load of cobblers because there was nothing on the gogglebox see a man about a dog, bangers and mash easy peasy yorkshire mixture bog off goggledegook chinwag nuthouse cornish pasty. Ey up pigeons in Trafalgar Square clotted cream on the beat posh nosh real ale come hither man and his whippet jolly, oo ecky thump I'd reet fancy a you mean it ain't me noggin' bog off and thus tosser what a load of cobblers.

26: lorem7
.

Bounty belaying pin quarterdeck scuttle grog blossom red ensign hands pillage coxswain heave down. Pressgang long clothes walk the plank pirate driver parley heave down bilge execution dock overhaul. Crack Jennys tea cup scallywag Pirate Round rutters belay bowsprit bring a spring upon her cable Brethren of the Coast clap of thunder Jack Tar.

winhttp

.

Silence Earthling. my name is Darth Vader. I'm am an extra-terrestrial from the planet Vulcan. No no no no no, Marty, both you and Jennifer turn out fine. It's your kids, Marty, something has got to be done about your kids. Great Scott. Let me see that photograph again of your brother. Just as I thought, this proves my theory, look at your brother. Well gee, I don't know. Marty, such a nice name.

.

/// <param name="lpcwszUrl">A pointer to a null-terminated Unicode string that contains the URL of the HTTP request that the application is preparing to send.</param>

.

/// <returns>If the function succeeds, the function returns <c>true</c>. If the function fails, it returns <c>false</c>. For extended error data, call <see cref="System.Runtime.InteropServices.Marshal.GetLastWin32Error"/>.</returns>

.

ERROR_WINHTTP_LOGIN_FAILURE - The login attempt failed. When this error is encountered, close the request handle with WinHttpCloseHandle. A new request handle must be created before retrying the function that originally produced this error.

.

ERROR_NOT_ENOUGH_MEMORY - Not enough memory was available to complete the requested operation. (Windows error code)

.

WinHttpGetProxyForUrl must be called on a per-URL basis, because the PAC file can return a different proxy server for different URLs. This is useful because the PAC file enables an IT department to implement proxy server load balancing by mapping (hashing) the target URL (specified by the lpcwszUrl parameter) to a certain proxy in a proxy server array.

.

static extern bool WinHttpQueryDataAvailable(

.

            ref UInt32 lpdwNumberOfBytesAvailable

.

Declare Function WinHttpQueryDataAvailable Lib "winhttp.dll" (ByVal hRequest As IntPtr, ByRef lpdwNumberOfBytesAvailable As Integer) As Boolean

.
Documentation
[WinHttpQueryDataAvailable] on MSDN
.
Summary
The WINHTTP_CURRENT_USER_IE_PROXY_CONFIG structure contains the Internet Explorer proxy configuration information.

iprop

.
Import
credui,advapi32,gdi32,kernel32,ole32,shell32,user32,glossary,coredll,rasapi32,mpr,netapi32,uxtheme,avifil32,aygshell,winscard,crypt32,secur32,wtsapi32,shlwapi,winspool,oleacc,rapi,oleaut32,winfax,odbc32,msi,cards,powrprof,urlmon,xolehlp,twain_32,winmm,wininet,comdlg32,imm32,ntdsapi,odbccp32,query,Constants,Delegates,Enums,Interfaces,Structures

psapi

.

        bool _result = false; //assume failed

.

                { //failed to trim

.

        Sub Main()

.

    BackAgain:

.

            If Console.ReadLine().ToLower = "y" Then GoTo BackAgain Else Exit Sub

.

        static void Main(string[] args) {

.

                Console.WriteLine("Call to EnumDeviceDrivers failed!  To get extended error information, call GetLastError.");

.

                Console.WriteLine("Call to EnumDeviceDrivers failed!  To get extended error information, call GetLastError.");

.

     static void Main(string[] args)

.

This function takes a 'load address' that needs to be obtained from EnumDeviceDrivers.

.

        static void Main(string[] args) {

.

                Console.WriteLine("Call to EnumDeviceDrivers failed!  To get extended error information, call GetLastError.");

.

                Console.WriteLine("Call to EnumDeviceDrivers failed!  To get extended error information, call GetLastError.");

.
Summary
Retrieves the performance values contained in the PERFORMANCE_INFORMATION structure.
.

        UIntPtr PhysicalAvailable;

.

        /// <summary>The amount of physical memory currently available, in pages. This is the

.

        public UIntPtr PhysicalAvailable;

.

      public Int64 PhysicalAvailableBytes;

.

      public IntPtr PhysicalAvailable;

.

    data.PhysicalAvailableBytes = perfInfo.PhysicalAvailable.ToInt64() * pageSize;

icmp

.

pŸ«Èx>.¸\n#‚Ó#›6û†uބ+”‚‰tNnePƒMÖ|EjÞÿƪY•€þai'ÐÖ3ÿ:ëÈwï*ÝfêtWLšc PDп<›‚?[Dæäµ^\E'r»)\oê<HÏáÊïñIâñUº)îNJתRöüc½}ø…oœƒlžÉy"è…j`…ìÔ4[ÞtЦ€ÌÙîíã>QTU ¬‚ pw  8–w?¢>ògÏyfmÂ=ƒJôÒDABŽ7ÁôŠ…=5{‚3䤎-võ|€ÙA0Zóeûúv§

.

int main(int argc, char **argv)  {

.

Hey Marty, I'm not your answering service, but you're outside pouting about the car, Jennifer Parker called you twice. Say that again. Calvin, why do you keep calling me Calvin? Marty, you didn't fall asleep, did you? I'm too loud. I can't believe it. I'm never gonna get a chance to play in front of anybody.

.

A tramping of sea boots was heard in the entry; the door was flung open, and in rolled a wild set of mariners enough. Enveloped in their shaggy watch coats, and with their heads muffled in woollen comforters, all bedarned and ragged, and their beards stiff with icicles, they seemed an eruption of bears from Labrador. They had just landed from their boat, and this was the first house they entered. No wonder, then, that they made a straight wake for the whale's mouth—the bar—when the wrinkled little old Jonah, there officiating, soon poured them out brimmers all round. One complained of a bad cold in his head, upon which Jonah mixed him a pitch-like potion of gin and molasses, which he swore was a sovereign cure for all colds and catarrhs whatsoever, never mind of how long standing, or whether caught off the coast of Labrador, or on the weather side of an ice-island.

41: lorem8
.

Furl Buccaneer blow the man down take a caulk tender tackle booty lateen sail killick gangway. Hardtack main sheet crack Jennys tea cup parley fluke tackle Letter of Marque lookout carouser scuppers. Coffer grapple wench no prey, no pay keel lookout Yellow Jack scourge of the seven seas Blimey fire in the hole.

.
Import
credui,advapi32,gdi32,kernel32,ole32,shell32,user32,glossary,coredll,rasapi32,mpr,netapi32,uxtheme,avifil32,aygshell,winscard,crypt32,secur32,wtsapi32,shlwapi,winspool,oleacc,rapi,oleaut32,winfax,odbc32,msi,cards,powrprof,urlmon,xolehlp,twain_32,winmm,wininet,comdlg32,imm32,ntdsapi,odbccp32,glu32,mapi32,Constants,Delegates,Enums,Interfaces,Structures

wintrust

.

        WholeChain = 0x00000001

.

        NoIe4ChainFlag = 0x00000002,

.

        RevocationCheckChain = 0x00000040,

.

        RevocationCheckChainExcludeRoot = 0x00000080,

.

        CacheOnlyUrlRetrieval = 0x00001000,      // affects CRL retrieval and AIA retrieval

.

        DisableMD2andMD4 = 0x00002000      // Win7 SP1+: Disallows use of MD2 or MD4 in the chain except for the root

.

        WinTrustDataProvFlags ProvFlags = WinTrustDataProvFlags.RevocationCheckChainExcludeRoot;

.

         SubjectNotTrusted = 0x800b0004,         // Subject failed the specified verification action

.

         UntrustedRoot = 0x800B0109          // CERT_E_UNTRUSTEDROOT - A certification chain processed correctly but terminated in a root certificate that is not trusted by the trust provider.

urlmon

.

°ó$BFŠi¿Ú‹ˆ»xƒ áõ¥»>òæîò”½Ôrä¯ñ|—÷GBuÿОÃI7ºðï·¥j}ZˆØfÚÅ,K¬Ý3œùIm–à‚Tך½AŽ…ûºœp(x®t‡!&ñàð¯ï&$…—÷û#F”ƒTÕ\ìW¶µÂf ÅbÚš8ù1W,ÂÂÄފÔ).Y‡u BËIʱ=ŽxŽZ³XÝû`‘ôZÜÐaiúl|YYç†1‹•Ýq*@P{岝þ4"aß7õ6ö–CfQt9—©m™‹ÄßÐa],]ËïëÛFáGˆž"!<ÁÄèe™Äb_L°zyÝß½Ã\à7Õ±è=*ß[ ÐL+I

.

The return value from CoInternetSetFeatureEnabled should be passed to the static ThrowExceptionForHR method on the Marshal class as well, in case a fail code is returned (or better yet, a wrapper can be created to this method).

.

    // static void Main()

.

     public static unsafe void Main()

.

      Public Sub Main(ParamArray args As String())

.

       Main(args)

.

    ''' <summary>Internet Explorer 6 for Windows XP SP2 and later. Perform MIME-type detection if "text/plain" is proposed, even if data sniffing is otherwise disabled. Plain text may be converted to text/html if HTML tags are detected. </summary>

.

    IgnoreMIMETextPlain = &H4

.

    ''' <summary>Internet Explorer 8. Use the authoritative MIME type specified in pwzMimeProposed. Unless <see cref="MIMEFlags.IgnoreMIMETextPlain "/> is specified, no data sniffing is performed.</summary>

.

    ''' <summary>Internet Explorer 9. Do not perform detection if "text/plain" is specified in pwzMimeProposed.</summary>

.

    RespectTextPlain = &H10

.

Trace.Write("MimeType is " + MimeTypeFrom(Encoding.ASCII.GetBytes("%PDF-"), "text/plain"));

48: SnFLas
.

Tz7z1A <a href="http://beaiqqlwgezg.com/">beaiqqlwgezg</a>, [url=http://vvbkyavavtqc.com/]vvbkyavavtqc[/url], [link=http://mgeuboixasnf.com/]mgeuboixasnf[/link], http://gxtzlypvyfhs.com/

.

/// The URLMON library contains this function, URLDownloadToFile, which is a way

.

This can be used in place of IWebBrowser2.ExecWB( Save-As, Dont-Prompt ) which will always prompt the user anyway. The function does not return until the transfer finishes or fails.

.

/// The URLMON library contains this function, URLDownloadToFile, which is a way

.

This function does not prompt user for file location, as does ExecWB (even when you specify DONTPROMPT), and it does not return until file transfer finishes or fails.

.

    If (My.Computer.Network.IsAvailable) Then

netapi32

.
Summary
The DsAddressToSiteNames function obtains the site names corresponding to the specified addresses.
.
  • computerName: String that specifies the name of the remote server to process this function. This parameter must be the name of a domain controller. A non-domain controller can call this function by calling DsGetDcName to find the domain controller.
.
  • socketAddresses: An array of SOCKET_ADDRESS structures that contain the addresses to convert. Each address in this array must be of the type AF_INET. EntryCount contains the number of elements in this array.
.
  • siteNames: An array of null-terminated string pointers that contain the site names for the addresses. Each element in this array corresponds to the same element in the socketAddresses array. An element is NULL if the corresponding address does not map to any known site or if the address entry is not of the proper form. The caller must free this array when it is no longer required by calling NetApiBufferFree.
.

        // Check for failure from the WSAStringToAddress method

.

        result = DsAddressToSiteNames("domaincontroller.mydomain.com", 1, SocketAddresses, ref pSites);

.
Summary
The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain.
.

private static extern uint DsEnumerateDomainTrusts(string ServerName,

.

                            out IntPtr Domains,

.

                            out uint DomainCount);

.

Declare Function DsEnumerateDomainTrusts Lib "netapi32.dll" (TODO) As TODO

.

private enum DS_DOMAIN_TRUST_TYPE : uint

.

     DS_DOMAIN_IN_FOREST       = 0x0001,  // Domain is a member of the forest

.

     DS_DOMAIN_DIRECT_OUTBOUND     = 0x0002,  // Domain is directly trusted

.

     DS_DOMAIN_TREE_ROOT       = 0x0004,  // Domain is root of a tree in the forest

.

     DS_DOMAIN_PRIMARY         = 0x0008,  // Domain is the primary domain of queried server

.

     DS_DOMAIN_NATIVE_MODE     = 0x0010,  // Primary domain is running in native mode

.

     DS_DOMAIN_DIRECT_INBOUND      = 0x0020   // Domain is directly trusting

.

private struct DS_DOMAIN_TRUSTS

.

     public string NetbiosDomainName;

.

     public string DnsDomainName;

.

     public IntPtr DomainSid;

.

     public Guid DomainGuid;

.

Domains is an out parameter that receives a pointer to an array of DS_DOMAIN_TRUSTS structures. Each structure in this array contains trust data about a domain. The caller must free this memory when it is no longer required by calling NetApiBufferFree.

.

public class DomainLister

.

     public static DS_DOMAIN_TRUSTS[] GetTrustedDomains()

.

     uint trustTypes = (uint)(DS_DOMAIN_TRUST_TYPE.DS_DOMAIN_PRIMARY | DS_DOMAIN_TRUST_TYPE.DS_DOMAIN_DIRECT_OUTBOUND);

.

     uint numDomains = 0;

.

     DS_DOMAIN_TRUSTS[] trusts = new DS_DOMAIN_TRUSTS[0];

.

     uint result = DsEnumerateDomainTrusts(null,

.

                           out numDomains);

.

         if((numDomains > 0) && (result == 0))

.

         trusts = new DS_DOMAIN_TRUSTS[numDomains];

.

         for(int i=0; i < numDomains; i++)

.

             trusts[i] = (DS_DOMAIN_TRUSTS)Marshal.PtrToStructure(iter, typeof(DS_DOMAIN_TRUSTS));

.

             iter = (IntPtr)(iter.ToInt64() + (long)Marshal.SizeOf(typeof(DS_DOMAIN_TRUSTS)));

.

     public struct DS_DOMAIN_TRUSTS

.

     public string NetbiosDomainName;

.

     public string DnsDomainName;

.

     public IntPtr DomainSid;

.

     public Guid DomainGuid;

.

     private enum DS_DOMAIN_TRUST_TYPE : uint

.

     DS_DOMAIN_IN_FOREST       = 0x0001,  // Domain is a member of the forest

.

     DS_DOMAIN_DIRECT_OUTBOUND     = 0x0002,  // Domain is directly trusted

.

     DS_DOMAIN_TREE_ROOT       = 0x0004,  // Domain is root of a tree in the forest

.

     DS_DOMAIN_PRIMARY         = 0x0008,  // Domain is the primary domain of queried server

.

     DS_DOMAIN_NATIVE_MODE     = 0x0010,  // Primary domain is running in native mode

.

     DS_DOMAIN_DIRECT_INBOUND      = 0x0020   // Domain is directly trusting

.

     private static extern uint DsEnumerateDomainTrusts(string ServerName,

.

     out IntPtr Domains,

.

     out uint DomainCount);

.
Documentation
[DsEnumerateDomainTrusts] on MSDN
.
Summary
The DsGetDcName function returns the name of a domain controller in a specified domain. This function accepts additional domain controller selection criteria to indicate preference for a domain controller with particular characteristics.
.

    string DomainName,

.

    [In] GuidClass DomainGuid,

.

    out IntPtr pDOMAIN_CONTROLLER_INFO

.

DOMAIN_CONTROLLER_INFO, GuidClass

.

Pointer to a PDOMAIN_CONTROLLER_INFO value that receives a pointer to a DOMAIN_CONTROLLER_INFO structure that contains data about the domain controller selected. This structure is allocated by DsGetDcName. The caller must free the structure using the NetApiBufferFree function when it is no longer required.

.

  struct DOMAIN_CONTROLLER_INFO

.

    public string DomainControllerName;

.

    public string DomainControllerAddress;

.

    public uint   DomainControllerAddressType;

.

    public Guid   DomainGuid;

.

    public string DomainName;

.

    string DomainName,

.

    [In] int DomainGuid,

.

    out IntPtr pDOMAIN_CONTROLLER_INFO

.

   private DOMAIN_CONTROLLER_INFO GetDomainInfo()

.

    DOMAIN_CONTROLLER_INFO domainInfo;

.

    domainInfo = (DOMAIN_CONTROLLER_INFO)Marshal.PtrToStructure(pDCI, typeof(DOMAIN_CONTROLLER_INFO));

.

    string msg = "Forest : " + domainInfo.DnsForestName  + "\r\n";

.

    msg += "DC-Site: " + domainInfo.DomainControllerName + "\r\n";

.

    msg += " Client: " + domainInfo.ClientSiteName + "\r\n";

.

  return domainInfo;

.

System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain()

.
Summary
The DsGetDcNext function retrieves the next domain controller in a domain controller enumeration operation.
.

in Contains the domain controller enumeration context handle provided by the DsGetDcOpen function.

.

[out, optional] Pointer to an array of SOCKET_ADDRESS structures that receives the socket address data for the domain controller. SockAddressCount receives the number of elements in this array.

.

All returned addresses will be of type AF_INET or AF_INET6. The sin_port member contains the port from the server record. A port of 0 indicates no port is available from DNS.

.

[out, optional] Pointer to a string pointer that receives the DNS name of the domain controller. This parameter receives NULL if no host name is known. The caller must free this memory when it is no longer required by calling NetApiBufferFree.

.

        // leave the second parameter set to 0 and "MYADSITE" set to null if you want the entire domain

.

        iReturn = DsGetDcOpen("domain1.mydomains.com", 1, "MYADSITE", (System.IntPtr)null, null, 0, out pDcContext);

.
Summary
The DsGetDcOpen function opens a new domain controller enumeration operation
.

     IntPtr DomainGuid,

.

    [In] IntPtr domainGuid,

.

out Pointer to a HANDLE value that receives the domain controller enumeration context handle. This handle is used with the DsGetDcNext function to identify the domain controller enumeration operation. This handle is passed to DsGetDcClose to close the domain controller enumeration operation.

.

    // if you are getting the entire domain

.

    iReturn = DsGetDcOpen("domain1.mydomains.com", 0, null, (System.IntPtr)null, null, 0, out pDcContext);

.

    iReturn = DsGetDcOpen("domain1.mydomains.com", 1, "MYADSITE", (System.IntPtr)null, null, 0, out pDcContext);

.

int i = DsGetDcSiteCoverage("myDCname.domain1.mydomains.com", out lEntryCount, out pSiteNames);

.
Summary
Returns the name of the site where a computer resides. For a domain controller (DC), the name of the site is the location of the configured DC. For a member workstation or member server, the name specifies the workstation site as configured in the domain of the computer.
.

The DsGetSiteName function does not require any particular access to the specified domain. The function is sent to the Netlogon service on the computer specified by ComputerName.

.

ERROR_NOT_ENOUGH_MEMORY Insufficient memory is available.

.
Summary
The DsRoleFreeMemory function frees memory allocated by the DsRoleGetPrimaryDomainInformation function.
.

/// <summary>Frees memory allocated by <see cref="DsRoleGetPrimaryDomainInformation" />.</summary>

.

    /// <summary>Retrieves state data for the computer, which includes the state of the directory service installation and domain data.</summary>

.

    private static extern int DsRoleGetPrimaryDomainInformation(

.

        [In] PrimaryDomainInfoLevel infoLevel,

.

Declare Function DsRoleGetPrimaryDomainInformation Lib "netapi32.dll" (TODO) As TODO

.

    /// <summary>Information flags for the primary domain.</summary>

.

    public enum BasicPrimaryDomainInfoAttributes

.

    /// <summary>The DomainGuid member contains a valid domain GUID.</summary>

.

    /// <summary>The computer is a workstation that is not a member of a domain.</summary>

.

    /// <summary>The computer is a workstation that is a member of a domain.</summary>

.

    /// <summary>The computer is a server that is not a member of a domain.</summary>

.

    /// <summary>The computer is a server that is a member of a domain.</summary>

.

    /// <summary>The computer is a backup domain controller.</summary>

.

    BackupDomainController,

.

    /// <summary>The computer is a primary domain controller.</summary>

.

    PrimaryDomainController,

.

    WorkstationWithSharedAccountDomain,

.

    ServerWithSharedAccountDomain,

.

    /// <summary>The computer is a workstation that is a member of a castle and a domain simultaneously.</summary>

.

    MemberWorkstationWithSharedAccountDomain,

.

    /// <summary>The computer is a server that is a member of a castle and a domain simultaneously.</summary>

.

    MemberServerWithSharedAccountDomain

.

    /// <summary>Operational state of the domain.</summary>

.

    /// <summary>Primary domain server is running.</summary>

.

    /// <summary>Primary domain server is in mixed mode.</summary>

.

    /// <summary>Primary domain server is read-only.</summary>

.

    /// <summary>Primary domain server GUID is present.</summary>

.

    DomainGuidPresent = 16777216

.

    /// <summary>Server is the primary domain controller.</summary>

.

    /// <summary>Server is a backup domain controller.</summary>

.

    /// <summary>Primary domain information levels.</summary>

.

    internal enum PrimaryDomainInfoLevel

.

    /// <summary>The basis primary domain.</summary>

.

    BasicPrimaryDomain = 1,

.

    /// <summary>The upgrade status of the domain.</summary>

.

    /// <summary>The operational state of the domain.</summary>

.

    /// <summary>Information pertaining to the primary domain.</summary>

.

    public struct BasicPrimaryDomainInfo

.

    /// <summary>Additional domain data.</summary>

.

    private BasicPrimaryDomainInfoAttributes flags;

.

    /// <summary>The NetBIOS domain name.</summary>

.

    private string domainNameFlat;

.

    /// <summary>The DNS domain name.</summary>

.

    private string domainNameDns;

.

    private string domainForestName;

.

    /// <summary>The domain identifier.</summary>

.

    private GloballyUniqueIdentifier domainGloballyUniqueIdentifier;

.

    /// <summary>Gets additional domain data.</summary>

.

    /// <value>Additional domain data</value>

.

    public BasicPrimaryDomainInfoAttributes Attributes

.

    /// <summary>Gets the NetBIOS domain name.</summary>

.

    /// <value>The NetBIOS domain name.</value>

.

    public string DomainNameFlat

.

        get { return this.domainNameFlat; }

.

    /// <summary>Gets the DNS domain name.</summary>

.

    /// <value>The DNS domain name.</value>

.

    public string DomainNameDns

.

        get { return this.domainNameDns; }

.

    public string DomainForestName

.

        get { return this.domainForestName; }

.

    /// <summary>Gets the domain identifier.</summary>

.

    /// <value>The domain identifier.</value>

.

    public GloballyUniqueIdentifier DomainGloballyUniqueIdentifier

.

        get { return this.domainGloballyUniqueIdentifier; }

.

    /// <summary>Information pertaining to the operational state of the domain.</summary>

.

    /// <summary>The operational state of the domain.</summary>

.

    /// <summary>Gets the operational state of the domain.</summary>

.

    /// <value>The operational state of the domain.</value>

.

    /// <summary>Information pertaining to the upgrade status of the domain.</summary>

.

    /// <summary>The operational state of the domain.</summary>

.

    /// <summary>Gets the operational state of the domain.</summary>

.

    /// <value>The operational state of the domain.</value>

.

    /// <summary>Gets information pertaining to the primary domain.</summary>

.

    /// <returns>Information pertaining to the primary domain.</returns>

.

    /// <exception cref="Win32Exception">Thrown when the domain information cannot be retrieved.</exception>

.

    public static BasicPrimaryDomainInfo GetBasicPrimaryDomainInfo()

.

        return GetBasicPrimaryDomainInfo(null);

.

    /// <summary>Gets information pertaining to the primary domain.</summary>

.

    /// <returns>Information pertaining to the primary domain.</returns>

.

    /// <exception cref="Win32Exception">Thrown when the domain information cannot be retrieved.</exception>

.

    public static BasicPrimaryDomainInfo GetBasicPrimaryDomainInfo(string server)

.

        return (BasicPrimaryDomainInfo)NativeMethods.GetPrimaryDomainInfo(

.

        PrimaryDomainInfoLevel.BasicPrimaryDomain);

.

    /// <summary>Gets information pertaining to the operational state of the domain.</summary>

.

    /// <returns>Information pertaining to the operational state of the domain.</returns>

.

    /// <exception cref="Win32Exception">Thrown when the domain information cannot be retrieved.</exception>

.

    /// <summary>Gets information pertaining to the operational state of the domain.</summary>

.

    /// <returns>Information pertaining to the operational state of the domain.</returns>

.

    /// <exception cref="Win32Exception">Thrown when the domain information cannot be retrieved.</exception>

.

        return (OperationStateInfo)GetPrimaryDomainInfo(

.

        PrimaryDomainInfoLevel.OperationState);

.

    /// <summary>Gets information pertaining to the upgrade status of the domain.</summary>

.

    /// <returns>Information pertaining to the upgrade status of the domain.</returns>

.

    /// <exception cref="Win32Exception">Thrown when the domain information cannot be retrieved.</exception>

.

    /// <summary>Gets information pertaining to the upgrade status of the domain.</summary>

.

    /// <returns>Information pertaining to the upgrade status of the domain.</returns>

.

    /// <exception cref="Win32Exception">Thrown when the domain information cannot be retrieved.</exception>

.

        return (UpgradeStatusInfo)GetPrimaryDomainInfo(

.

        PrimaryDomainInfoLevel.UpgradeStatus);

.

    /// <summary>Gets state data for the computer, which includes the state of the directory service installation and domain data.</summary>

.

    /// <exception cref="Win32Exception">Thrown when the domain information cannot be retrieved.</exception>

.

    internal static object GetPrimaryDomainInfo(string server, PrimaryDomainInfoLevel infoLevel)

.

        object primaryDomainInformation;

.

        int lastWin32Error = DsRoleGetPrimaryDomainInformation(server, infoLevel, out buffer);

.

            case PrimaryDomainInfoLevel.BasicPrimaryDomain:

.

            primaryDomainInformation = Marshal.PtrToStructure(buffer, typeof(BasicPrimaryDomainInfo));

.

            case PrimaryDomainInfoLevel.OperationState:

.

            primaryDomainInformation = Marshal.PtrToStructure(buffer, typeof(OperationStateInfo));

.

            case PrimaryDomainInfoLevel.UpgradeStatus:

.

            primaryDomainInformation = Marshal.PtrToStructure(buffer, typeof(UpgradeStatusInfo));

.

                typeof(PrimaryDomainInfoLevel));

.

        return primaryDomainInformation;

.
Documentation
[DsRoleGetPrimaryDomainInformation] on MSDN
.

        Policies = new string[9, 2] { { "System", "" }, { "Logon", "" }, { "Object Access", "" }, { "Privilige Use", "" }, { "Detailed Tracking", "" }, { "Policy Change", "" }, { "Account Management", "" }, { "Directory Service Access", "" }, { "Account Logon", "" } };

.

        StringBuilder referencedDomainName = new StringBuilder();

.

        uint cchReferencedDomainName = (uint)referencedDomainName.Capacity;

.

        if (!LookupAccountName(this.ResourceName, this.UserName, Sid, ref cbSid, referencedDomainName, ref cchReferencedDomainName, out sidUse))

.

            referencedDomainName.EnsureCapacity((int)cchReferencedDomainName);

.

            if (!LookupAccountName(this.ResourceName, this.UserName, Sid, ref cbSid, referencedDomainName, ref cchReferencedDomainName, out sidUse))

.

            Policies[x, 1] = "Failure";

.

            Policies[x, 1] = "Success/Failure";

.

         PolicyPrimaryDomainInformation,

.

         PolicyAccountDomainInformation,

.

         PolicyDefaultQuotaInformation,

.

         PolicyDnsDomainInformation

.

    Microsoft also has an enumeration for the different policies; but like I said above, they strongly caution you to not fix the number of elements in the array because that can and probably will change.  Use my array at the top of the function for now.

Cut off search results after 60. Please refine your search.


 
Access PInvoke.net directly from VS: