< Back

Get-LdapConnection

Sat Jan 18, 2020 9:42 am

NAME Get-LdapConnection



SYNOPSIS

Returns a new LdapConnection object





SYNTAX

Get-LdapConnection [-Server] <String> [[-Port] <Int32>] [[-Credential] <PSCredential>] [[-AuthType] {Anonymous |

Basic | Negotiate | Ntlm | Digest | Sicily | Dpa | Msn | External | Kerberos}] [-IgnoreCertificate] [-NoSsl]

[<CommonParameters>]





DESCRIPTION

This function returns a new LdapConnection object, which can be used to query LDAP.



This function does not actually bind to LDAP - binding is done either with the .Bind() method on the output

object, or automatically when running a query with the output object.



Be sure to close the LdapConnection object after querying! This can be done with the Remove-LdapConnection

function by calling .Dispose() on the object.





PARAMETERS

-AuthType <AuthType>

Type of LDAP authentication to use. If not specified, defaults are Anonymous if no credentials are provided,

or Basic if credentials are provided.



Required? false

Position? 3

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Credential <PSCredential>

Credentials to use to connect to LDAP. Note that in most cases, a fully-qualified name is required (such as

"cn=User,ou=Example,dc=local") rather than just a common name.



For more information about using credentials in PowerShell, see the help documentation on the native

Get-Credential cmdlet by running "help Get-Credential".



Required? false

Position? 2

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-IgnoreCertificate [<SwitchParameter>]

Do not validate the SSL certificate from the LDAP server.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-NoSsl [<SwitchParameter>]

Do not attempt to use SSL encryption.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Port <Int32>

Port to be used to connect to LDAP.



Required? false

Position? 1

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Server <String>

FQDN of the LDAP server to connect to.



Required? true

Position? 0

Default value None

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

None







OUTPUTS

System.DirectoryServices.Protocols.LdapDirectoryIdentifier







NOTES









-------------------------- Example 1 --------------------------



PS C:\\> Get-LdapConnection -Server 'example.local' -Port 636



This example returns a new LdapConnection object with the provided server and port, using anonymous access.

-------------------------- Example 2 --------------------------



PS C:\\> Get-LdapConnection -Server 'example.local' -Port 636 -Credential (Get-Credential)



This example returns a new LdapConnection object with the provided server and port using basic authentication,

using credentials provided by Get-Credential.



RELATED LINKS

Remove-LdapConnection