📄 ntdsapi.h
字号:
// ********************
// Perform this operation asynchronously.
#define DS_REPDEL_ASYNCHRONOUS_OPERATION 0x00000001
// The replica being deleted is writeable.
#define DS_REPDEL_WRITEABLE 0x00000002
// Replica is a mail-based replica
#define DS_REPDEL_INTERSITE_MESSAGING 0x00000004
// Ignore any error generated by contacting the source to tell it to scratch
// this server from its Reps-To for this NC.
#define DS_REPDEL_IGNORE_ERRORS 0x00000008
// Do not contact the source telling it to scratch this server from its
// Rep-To for this NC. Otherwise, if the link is RPC-based, the source will
// be contacted.
#define DS_REPDEL_LOCAL_ONLY 0x00000010
// Delete all the objects in the NC
// "No source" is incompatible with (and rejected for) writeable NCs. This is
// valid only for read-only NCs, and then only if the NC has no source. This
// can occur when the NC has been partially deleted (in which case the KCC
// periodically calls the delete API with the "no source" flag set).
#define DS_REPDEL_NO_SOURCE 0x00000020
// Allow deletion of read-only replica even if it sources
// other read-only replicas.
#define DS_REPDEL_REF_OK 0x00000040
// ********************
// Replica Modify flags
// ********************
// Perform this operation asynchronously.
#define DS_REPMOD_ASYNCHRONOUS_OPERATION 0x00000001
// The replica is writeable.
#define DS_REPMOD_WRITEABLE 0x00000002
// ********************
// Replica Modify fields
// ********************
#define DS_REPMOD_UPDATE_FLAGS 0x00000001
#define DS_REPMOD_UPDATE_ADDRESS 0x00000002
#define DS_REPMOD_UPDATE_SCHEDULE 0x00000004
#define DS_REPMOD_UPDATE_RESULT 0x00000008
#define DS_REPMOD_UPDATE_TRANSPORT 0x00000010
// ********************
// Update Refs fields
// ********************
// Perform this operation asynchronously.
#define DS_REPUPD_ASYNCHRONOUS_OPERATION 0x00000001
// The replica being deleted is writeable.
#define DS_REPUPD_WRITEABLE 0x00000002
// Add a reference
#define DS_REPUPD_ADD_REFERENCE 0x00000004
// Remove a reference
#define DS_REPUPD_DELETE_REFERENCE 0x00000008
// ***********************
// Well Known Object Guids
// ***********************
#define GUID_USERS_CONTAINER_A "a9d1ca15768811d1aded00c04fd8d5cd"
#define GUID_COMPUTRS_CONTAINER_A "aa312825768811d1aded00c04fd8d5cd"
#define GUID_SYSTEMS_CONTAINER_A "ab1d30f3768811d1aded00c04fd8d5cd"
#define GUID_DOMAIN_CONTROLLERS_CONTAINER_A "a361b2ffffd211d1aa4b00c04fd7d83a"
#define GUID_INFRASTRUCTURE_CONTAINER_A "2fbac1870ade11d297c400c04fd8d5cd"
#define GUID_DELETED_OBJECTS_CONTAINER_A "18e2ea80684f11d2b9aa00c04f79f805"
#define GUID_LOSTANDFOUND_CONTAINER_A "ab8153b7768811d1aded00c04fd8d5cd"
#define GUID_USERS_CONTAINER_W L"a9d1ca15768811d1aded00c04fd8d5cd"
#define GUID_COMPUTRS_CONTAINER_W L"aa312825768811d1aded00c04fd8d5cd"
#define GUID_SYSTEMS_CONTAINER_W L"ab1d30f3768811d1aded00c04fd8d5cd"
#define GUID_DOMAIN_CONTROLLERS_CONTAINER_W L"a361b2ffffd211d1aa4b00c04fd7d83a"
#define GUID_INFRASTRUCTURE_CONTAINER_W L"2fbac1870ade11d297c400c04fd8d5cd"
#define GUID_DELETED_OBJECTS_CONTAINER_W L"18e2ea80684f11d2b9aa00c04f79f805"
#define GUID_LOSTANDFOUND_CONTAINER_W L"ab8153b7768811d1aded00c04fd8d5cd"
#define GUID_USERS_CONTAINER_BYTE "\xa9\xd1\xca\x15\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
#define GUID_COMPUTRS_CONTAINER_BYTE "\xaa\x31\x28\x25\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
#define GUID_SYSTEMS_CONTAINER_BYTE "\xab\x1d\x30\xf3\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
#define GUID_DOMAIN_CONTROLLERS_CONTAINER_BYTE "\xa3\x61\xb2\xff\xff\xd2\x11\xd1\xaa\x4b\x00\xc0\x4f\xd7\xd8\x3a"
#define GUID_INFRASTRUCTURE_CONTAINER_BYTE "\x2f\xba\xc1\x87\x0a\xde\x11\xd2\x97\xc4\x00\xc0\x4f\xd8\xd5\xcd"
#define GUID_DELETED_OBJECTS_CONTAINER_BYTE "\x18\xe2\xea\x80\x68\x4f\x11\xd2\xb9\xaa\x00\xc0\x4f\x79\xf8\x05"
#define GUID_LOSTANDFOUND_CONTAINER_BYTE "\xab\x81\x53\xb7\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
//////////////////////////////////////////////////////////////////////////
// //
// Prototypes //
// //
//////////////////////////////////////////////////////////////////////////
// DSBind takes two optional input parameters which identify whether the
// caller found a domain controller themselves via DsGetDcName or whether
// a domain controller should be found using default parameters.
// Behavior of the possible combinations are outlined below.
//
// DomainControllerName(value), DnsDomainName(NULL)
//
// The value for DomainControllerName is assumed to have been
// obtained via DsGetDcName (i.e. Field with the same name in a
// DOMAIN_CONTROLLER_INFO struct on return from DsGetDcName call.)
// The client is bound to the domain controller at this name.
//
// Mutual authentication will be performed using an SPN of
// LDAP/DomainControllerName provided DomainControllerName
// is not a NETBIOS name or IP address - i.e. it must be a
// DNS host name.
//
// DomainControllerName(value), DnsDomainName(value)
//
// DsBind will connect to the server identified by DomainControllerName.
//
// Mutual authentication will be performed using an SPN of
// LDAP/DomainControllerName/DnsDomainName provided neither value
// is a NETBIOS names or IP address - i.e. they must be
// valid DNS names.
//
// DomainControllerName(NULL), DnsDomainName(NULL)
//
// DsBind will attempt to find to a global catalog and fail if one
// can not be found.
//
// Mutual authentication will be performed using an SPN of
// GC/DnsHostName/ForestName where DnsHostName and ForestName
// represent the DomainControllerName and DnsForestName fields
// respectively of the DOMAIN_CONTROLLER_INFO returned by the
// DsGetDcName call used to find a global catalog.
//
// DomainControllerName(NULL), DnsDomainName(value)
//
// DsBind will attempt to find a domain controller for the domain
// identified by DnsDomainName and fail if one can not be found.
//
// Mutual authentication will be performed using an SPN of
// LDAP/DnsHostName/DnsDomainName where DnsDomainName is that
// provided by the caller and DnsHostName is that returned by
// DsGetDcName for the domain specified - provided DnsDomainName
// is a valid DNS domain name - i.e. not a NETBIOS domain name.
NTDSAPI
DWORD
WINAPI
DsBindW(
LPCWSTR DomainControllerName, // in, optional
LPCWSTR DnsDomainName, // in, optional
HANDLE *phDS);
NTDSAPI
DWORD
WINAPI
DsBindA(
LPCSTR DomainControllerName, // in, optional
LPCSTR DnsDomainName, // in, optional
HANDLE *phDS);
#ifdef UNICODE
#define DsBind DsBindW
#else
#define DsBind DsBindA
#endif
NTDSAPI
DWORD
WINAPI
DsBindWithCredW(
LPCWSTR DomainControllerName, // in, optional
LPCWSTR DnsDomainName, // in, optional
RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
HANDLE *phDS);
NTDSAPI
DWORD
WINAPI
DsBindWithCredA(
LPCSTR DomainControllerName, // in, optional
LPCSTR DnsDomainName, // in, optional
RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
HANDLE *phDS);
#ifdef UNICODE
#define DsBindWithCred DsBindWithCredW
#else
#define DsBindWithCred DsBindWithCredA
#endif
//
// DsBindWithSpn{A|W} allows the caller to specify the service principal
// name (SPN) which will be used for mutual authentication against
// the destination server. Do not provide an SPN if you are expecting
// DsBind to find a server for you as SPNs are machine specific and its
// unlikely the SPN you provide matches the server DsBind finds for you.
// Providing a NULL ServicePrincipalName argument results in behavior
// identical to DsBindWithCred{A|W}.
//
NTDSAPI
DWORD
WINAPI
DsBindWithSpnW(
LPCWSTR DomainControllerName, // in, optional
LPCWSTR DnsDomainName, // in, optional
RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
LPCWSTR ServicePrincipalName, // in, optional
HANDLE *phDS);
NTDSAPI
DWORD
WINAPI
DsBindWithSpnA(
LPCSTR DomainControllerName, // in, optional
LPCSTR DnsDomainName, // in, optional
RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
LPCSTR ServicePrincipalName, // in, optional
HANDLE *phDS);
#ifdef UNICODE
#define DsBindWithSpn DsBindWithSpnW
#else
#define DsBindWithSpn DsBindWithSpnA
#endif
//
// DsUnBind
//
NTDSAPI
DWORD
WINAPI
DsUnBindW(
HANDLE *phDS); // in
NTDSAPI
DWORD
WINAPI
DsUnBindA(
HANDLE *phDS); // in
#ifdef UNICODE
#define DsUnBind DsUnBindW
#else
#define DsUnBind DsUnBindA
#endif
//
// DsMakePasswordCredentials
//
// This function constructs a credential structure which is suitable for input
// to the DsBindWithCredentials function, or the ldap_open function (winldap.h)
// The credential must be freed using DsFreeCredential.
//
// None of the input parameters may be present indicating a null, default
// credential. Otherwise the username must be present. If the domain or
// password are null, they default to empty strings. The domain name may be
// null when the username is fully qualified, for example UPN format.
//
NTDSAPI
DWORD
WINAPI
DsMakePasswordCredentialsW(
LPCWSTR User,
LPCWSTR Domain,
LPCWSTR Password,
RPC_AUTH_IDENTITY_HANDLE *pAuthIdentity
);
NTDSAPI
DWORD
WINAPI
DsMakePasswordCredentialsA(
LPCSTR User,
LPCSTR Domain,
LPCSTR Password,
RPC_AUTH_IDENTITY_HANDLE *pAuthIdentity
);
#ifdef UNICODE
#define DsMakePasswordCredentials DsMakePasswordCredentialsW
#else
#define DsMakePasswordCredentials DsMakePasswordCredentialsA
#endif
NTDSAPI
VOID
WINAPI
DsFreePasswordCredentials(
RPC_AUTH_IDENTITY_HANDLE AuthIdentity
);
#define DsFreePasswordCredentialsW DsFreePasswordCredentials
#define DsFreePasswordCredentialsA DsFreePasswordCredentials
//
// DsCrackNames
//
NTDSAPI
DWORD
WINAPI
DsCrackNamesW(
HANDLE hDS, // in
DS_NAME_FLAGS flags, // in
DS_NAME_FORMAT formatOffered, // in
DS_NAME_FORMAT formatDesired, // in
DWORD cNames, // in
const LPCWSTR *rpNames, // in
PDS_NAME_RESULTW *ppResult); // out
NTDSAPI
DWORD
WINAPI
DsCrackNamesA(
HANDLE hDS, // in
DS_NAME_FLAGS flags, // in
DS_NAME_FORMAT formatOffered, // in
DS_NAME_FORMAT formatDesired, // in
DWORD cNames, // in
const LPCSTR *rpNames, // in
PDS_NAME_RESULTA *ppResult); // out
#ifdef UNICODE
#define DsCrackNames DsCrackNamesW
#else
#define DsCrackNames DsCrackNamesA
#endif
//
// DsFreeNameResult
//
NTDSAPI
void
WINAPI
DsFreeNameResultW(
DS_NAME_RESULTW *pResult); // in
NTDSAPI
void
WINAPI
DsFreeNameResultA(
DS_NAME_RESULTA *pResult); // in
#ifdef UNICODE
#define DsFreeNameResult DsFreeNameResultW
#else
#define DsFreeNameResult DsFreeNameResultA
#endif
// ==========================================================
// DSMakeSpn -- client call to create SPN for a service to which it wants to
// authenticate.
// This name is then passed to "pszTargetName" of InitializeSecurityContext().
//
// Notes:
// If the service name is a DNS host name, or canonical DNS service name
// e.g. "www.ms.com", i.e., caller resolved with gethostbyname, then instance
// name should be NULL.
// Realm is host name minus first component, unless it is in the exception list
//
// If the service name is NetBIOS machine name, then instance name should be
// NULL
// Form must be <domain>\<machine>
// Realm will be <domain>
//
// If the service name is that of a replicated service, where each replica has
// its own account (e.g., with SRV records) then the caller must supply the
// instance name then realm name is same as ServiceName
//
// If the service name is a DN, then must also supply instance name
// (DN could be name of service object (incl RPC or Winsock), name of machine
// account, name of domain object)
// then realm name is domain part of the DN
//
// If the service name is NetBIOS domain name, then must also supply instance
// name; realm name is domain name
//
// If the service is named by an IP address -- then use referring service name
// as service name
//
// ServiceClass - e.g. "http", "ftp", "ldap", GUID
// ServiceName - DNS or DN; assumes we can compute domain from service name
// InstanceName OPTIONAL- DNS name of host for instance of service
// InstancePort - port number for instance (0 if default)
// Referrer OPTIONAL- DNS name of host that gave this referral
// pcSpnLength - in -- max length IN CHARACTERS of principal name;
// out -- actual
// Length includes terminator
// pszSPN - server principal name
//
// If buffer is not large enough, ERROR_BUFFER_OVERFLOW is returned and the
// needed length is returned in pcSpnLength.
//
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -