.net in run book help

Discussion in '.NET' started by Glen, May 5, 2016.

  1. Glen

    Glen

    Joined:
    May 4, 2016
    Messages:
    1
    Likes Received:
    0
    Hi , i am very new to this .net stuff i am trying to integrate some .net scripts within a Orchestrator run books

    The bellow code seems to work but i get a this error when ever i run it through the run book and all my start and end subs seem to be in the right spot.

    any help would be much apreciated

    C:\Users\user\AppData\Local\Microsoft System Center 2012\Orchestrator\Activities\RunScript\hb-xeojs.0.vb(6,0) : error BC30289: Statement cannot appear within a method body. End of method assumed.C:\Users\user\AppData\Local\Microsoft System Center 2012\Orchestrator\Activities\RunScript\hb-xeojs.0.vb(44,0) : error BC30429: 'End Sub' must be preceded by a matching 'Sub'.


    Imports System.DirectoryServices

    Module Module1
    Public Sub SetADProperty(ByVal de As DirectoryEntry, ByVal pName As String, ByVal pValue As String)
    If Not pValue Is Nothing Then
    If de.Properties.Contains(pName) Then 'The DE contains this property
    de.Properties(pName)(0) = pValue
    Else
    de.Properties(pName).Add(pValue)
    End If
    End If
    End Sub
    Public Function GetDirectoryEntry() As DirectoryEntry
    Dim dirEntry As New DirectoryEntry("LDAP://mydomain")
    dirEntry.Username = Nothing
    dirEntry.Password = Nothing
    dirEntry.AuthenticationType = AuthenticationTypes.Secure
    Return dirEntry
    End Function
    Public Sub UpdateUserADAccount(ByVal userLogin As String, ByVal userDepartment As String, ByVal userTitle As String, ByVal userPhoneExt As String)
    Dim dirEntry As DirectoryEntry = GetDirectoryEntry()
    Dim dirSearcher As DirectorySearcher = New DirectorySearcher(dirEntry)
    dirSearcher.Filter = "(&(objectCategory=Person)(objectClass=user) (SAMAccountName=" & userLogin & "))"
    dirSearcher.SearchScope = SearchScope.Subtree
    Dim searchResults As SearchResult = dirSearcher.FindOne()
    If Not searchResults Is Nothing Then
    Dim dirEntryResults As New DirectoryEntry(searchResults.Path)
    SetADProperty(dirEntryResults, "department", userDepartment)
    SetADProperty(dirEntryResults, "title", userTitle)
    SetADProperty(dirEntryResults, "phone", userPhoneExt)
    dirEntryResults.CommitChanges()
    dirEntryResults.Close()
    End If
    dirEntry.Close()
    End Sub
    Sub Main()
    UpdateUserADAccount("Testuser", "HR", "Noone", "000")
    End Sub
    End Module
     
    Glen, May 5, 2016
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Saul
    Replies:
    1
    Views:
    578
    Zenobia
    Jun 25, 2004
  2. Jason Williard

    Book Recommendation Request: VB.NET & C#.NET

    Jason Williard, Sep 21, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    612
    Brian Bischof
    Sep 22, 2004
  3. Nathan Sokalski
    Replies:
    2
    Views:
    508
  4. Thanasis \(sch\)

    awt book+java animation book

    Thanasis \(sch\), Oct 13, 2004, in forum: Java
    Replies:
    1
    Views:
    924
    Alex Hunsley
    Oct 14, 2004
  5. kb1381
    Replies:
    1
    Views:
    448
    kb1381
    Aug 25, 2005
  6. coltrane
    Replies:
    2
    Views:
    793
    coltrane
    Sep 27, 2006
  7. Bit Byte
    Replies:
    1
    Views:
    1,162
    Teemu Keiski
    Jan 28, 2007
  8. Gio

    Puzzle Book & Answer Book

    Gio, Apr 17, 2008, in forum: C Programming
    Replies:
    1
    Views:
    671
    santosh
    Apr 17, 2008
Loading...