The AddLdapUser method creates a new FPCNonWindowsUser object in the collection for an LDAP user and returns a reference to it.
HRESULT AddLdapUser( [in] BSTR Username, [in] BSTR LdapServerUsername, [in] BSTR LdapServerUserPassword, [in] BSTR LdapServerSetName, [out] IFPCNonWindowsUser** ppNonWindowsUser );
Address of an interface pointer that on return points to the new IFPCNonWindowsUser interface created.
This method can return one of the following:
Function AddLdapUser( _ ByVal Username As String, _ ByVal LdapServerUsername As String, _ ByVal LdapServerUserPassword As String, _ ByVal LdapServerSetName As String _ ) As FPCNonWindowsUser
This method returns a reference to an FPCNonWindowsUser object if successful. Otherwise, an error is raised that can be intercepted by using an error handler.
Option Explicit 'Define the constants needed Const Error_FileNotFound = &H80070002 Const Error_AccessDenied = &H80070005 Const Error_IncorrectParameter = &H80070057 Const Error_AlreadyExists = &H800700B7 Main(WScript.Arguments) Sub Main(args) If(args.Count <> 4) Then Usage() End If AddLdapUsers args(0), args(1), args(2), args(3) End Sub Sub AddLdapUsers(userSetName, ldapServerSet, userName, password) ' Create the root object. Dim root ' The FPCLib.FPC root object Set root = CreateObject("FPC.Root") 'Declare the other objects needed. Dim isaArray ' An FPCArray object Dim userSets ' An FPCUserSets collection Dim userSet ' An FPCUserSet object Dim nwUsers ' An FPCNonWindowsUsers collection Dim input ' A String ' Get references to the array object and the user sets collection. Set isaArray = root.GetContainingArray() Set userSets = isaArray.RuleElements.UserSets ' Get a reference to the user set specified by the user. On Error Resume Next Set userSet = userSets.Item(userSetName) If err.Number = Error_FileNotFound Then WScript.Echo "The user set " & userSetName & " does not exist. Aborting ..." WScript.Quit End If On Error GoTo 0 ' Get a reference the collection of non-Windows users in the user set. Set nwUsers = userSet.NonWindowsUsers Do input = InputBox("Name of the LDAP user to add (or Quit to exit)", ,"Quit") If input = "Quit" Then Exit Do End If On Error Resume Next nwUsers.AddLdapUser input, userName, password, ldapServerSet If err.Number = Error_IncorrectParameter Then WScript.Echo "The LDAP server set specified does not exit, " _ & "or the operation was canceled." Err.Clear WScript.Quit ElseIf err.Number = Error_AccessDenied Then WScript.Echo "Access to the LDAP server was denied." Err.Clear WScript.Quit ElseIf err.Number = Error_AlreadyExists Then WScript.Echo "The user " & input & " is already an LDAP user." Err.Clear ElseIf err.Number <> 0 Then WScript.Echo "An error occurred: 0x" & Hex(Err.Number) & " " & Err.Description Err.Clear WScript.Quit Else WScript.Echo "The user " & input & " was added as an LDAP user." End If On Error GoTo 0 Loop ' Save changes. userSet.Save WScript.Echo "Done!" End Sub Sub Usage() WScript.Echo "Usage:" & VbCrLf _ & " " & WScript.ScriptName & " UserSet LdapServerSet UserName Password" & VbCrLf _ & "" & VbCrLf _ & " UserSet - Name of the user set" & VbCrLf _ & " LdapServerSet - Name of the LDAP server set" & VbCrLf _ & " UserName - User name for accessing an LDAP server" & VbCrLf _ & " Password - Password for accessing an LDAP server" WScript.Quit End Sub
If a user name is specified in the domain\user-name format in the Username parameter, the domain name will be ignored.
Client | Requires Windows Vista or Windows XP. |
---|---|
Server | Requires Windows Server 2008. |
Version | Requires Forefront Threat Management Gateway (TMG). |
IDL |
Declared in Msfpccom.idl. |
DLL |
Requires Msfpccom.dll. |
Send comments about this topic to Microsoft
Build date: 11/30/2009
© 2008 Microsoft Corporation. All rights reserved.