CreateGPOLink function (gpedit.h)

The CreateGPOLink function creates a link between the specified GPO and the specified site, domain, or organizational unit.

Syntax

GPEDITAPI HRESULT CreateGPOLink(
  [in] LPOLESTR lpGPO,
  [in] LPOLESTR lpContainer,
  [in] BOOL     fHighPriority
);

Parameters

[in] lpGPO

A value that specifies the path to the GPO, in ADSI format ("LDAP://cn=user, ou=users, dc=coname, dc=com"). You cannot specify a server name in this parameter.

[in] lpContainer

A value that specifies the Active Directory path to the site, domain, or organizational unit.

[in] fHighPriority

A value that specifies the link priority. If this parameter is TRUE, the system creates the link as the highest priority. If this parameter is FALSE, the system creates the link as the lowest priority.

Return value

If the function succeeds, the return value is S_OK. Otherwise, the function returns one of the COM error codes defined in the header file WinError.h. Be aware that you should test explicitly for the return value S_OK. Do not use the SUCCEEDED or FAILED macro on the returned HRESULT to determine success or failure of the function.

Requirements

Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header gpedit.h
Library GPEdit.lib
DLL GPEdit.dll

See also

DeleteAllGPOLinks

DeleteGPOLink

Group Policy Functions

Group Policy Overview