Extension to provision users (Visual Basic)
This code can be found in
Chapter 23 of Active Directory Cookbook, 2nd edition
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Visual Basic code from this site.
Public Sub Provision(ByVal mventry As MVEntry) Implements _
IMVSynchronization.Provision
Dim container As String
Dim rdn As String
Dim ADMA As ConnectedMA
Dim numConnectors As Integer
Dim myConnector As CSEntry
Dim csentry As CSEntry
Dim dn As ReferenceValue
' Ensure that the cn attribute is present.
If Not mventry("cn").IsPresent Then
Throw New UnexpectedDataException("cn attribute is not present.")
End If
' Calculate the container and RDN.
container = "CN=users,DC=rallencorp,DC=com"
rdn = "CN=" & mventry("cn").Value
ADMA = mventry.ConnectedMAs("rallencorp.com")
dn = ADMA.EscapeDNComponent(rdn).Concat(container)
numConnectors = ADMA.Connectors.Count
' create a new connector.
If numConnectors = 0 Then
csentry = ADMA.Connectors.StartNewConnector("user")
csentry.DN = dn
csentry(“unicodePwd”).Value = “Password1”
csentry.CommitNewConnector()
ElseIf numConnectors = 1 Then
' If the connector has a different DN rename it.
myConnector = ADMA.Connectors.ByIndex(0)
myConnector.DN = dn
Else
Throw New UnexpectedDataException("Error: There are" + _
numConnectors.ToString + " connectors")
End If
End Sub
|
This code has been viewed 2571 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|