CreateGPOLink function

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

Syntax

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

Parameters

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.

lpContainer

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

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

   
Windows version Windows Vista 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