Your Ad Here

Calendar

March 2010
SunMonTueWedThuFriSat
 << < > >>
 123456
78910111213
14151617181920
21222324252627
28293031   

Announce

Who's Online?

Member: 0
Visitor: 1

rss Syndication

Archives

Anything u Want

15 May 2008 - 12:55:53 pm
Assign a new Group policy to Organizational Unit

/* Assign a new Group policy to Organizational Unit */

On Error Resume Next

Set objContainer = GetObject _
    ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")
 
strExistingGPLink = objContainer.Get("gPLink")
 
strGPODisplayName = "Sales Policy"
strGPOLinkOptions = 2
strNewGPLink = "[" & GetGPOADsPath & ";" & strGPOLinkOptions & "]"
 
objContainer.Put "gPLink", strExistingGPLink & strNewGPLink
objContainer.Put "gPOptions", "0"
 
objContainer.SetInfo
 
Function GetGPOADsPath
    Set objConnection = CreateObject("ADODB.Connection") 
    objConnection.Open "Provider=ADsDSOObject;"  
 
    Set objCommand = CreateObject("ADODB.Command")
    objCommand.ActiveConnection = objConnection
 
    objCommand.CommandText = _
      "<LDAP://cn=Policies,cn=System,dc=NA,dc=fabrikam,dc=com>;;" & _
          "distinguishedName,displayName;onelevel"
    Set objRecordSet = objCommand.Execute
 
    Do Until objRecordSet.EOF
        If objRecordSet.Fields("displayName") = strGPODisplayName Then
          GetGPOADsPath = "LDAP://" & objRecordSet.Fields("distinguishedName")
          objConnection.Close
          Exit Function
        End If
        objRecordSet.MoveNext
    Loop
    objConnection.Close
End Function


harvey_kumar · 157 views · 0 comments

Permanent link to full entry

http://dotnet.sosblog.com/Anything-u-want-b1/Assign-a-new-Group-policy-to-Organizational-Unit-b1-p14.htm

Comments

No Comment for this post yet...


Leave a comment

New feedback status: Published





Your URL will be displayed.

 
Please enter the code written in the picture.


Comment text

Options
   (Set cookies for name, email and url)