jaenu1989
Goto Top

ASP Public Function in Dim Variable speichern

Hallo Zusammen ich hätte wiedereinmal eine Frage.

Ich habe eine Funktion geschrieben, die die Mail adresse eines Users aus dem AD heraussucht und ausgibt. Nun möchte ich die Ausgabe dieser funktion in einer Variable speichern.
Mein Problem liegt glaub dadrin dass ich den Wald lauter Bäume nicht mehr sehe. Ich glaube eigentlich ist es ganz banal und einfach aber ich komme nicht drauf!

Meine Funktion:

response.write GetMailAddress(*USERNAME","*DOMÄNE*","","")

Public Function GetMailAddress(strUsername, strDnsDomain, strAccount, strPassword)

Dim objConnection, objCommand, objRecordSet
Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"

objConnection.Properties("User ID") = "*AD-USER*"
objConnection.Properties("Password") = "*AD-USER-PASSWORT*"
objConnection.Properties("Encrypt Password") = True
objConnection.Properties("ADSI Flag") = 1

objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.CommandText = "SELECT mail FROM 'LDAP://" & strDnsDomain & "' WHERE objectCategory='user' AND Name='" & strUsername & "'"

On Error Resume Next
Set objRecordSet = objCommand.Execute

If Err.Number <> 0 Then Exit Function

objRecordSet.MoveFirst

GetMailAddress=objRecordSet.Fields("mail").Value

Set objConnection = Nothing
Set objCommand = Nothing
Set objRecordSet = Nothing

End Function


Diese funktion will ich in eine Dim Variable speichern!

Danke schon jetzt für die Antworten!

Content-Key: 141241

Url: https://administrator.de/contentid/141241

Printed on: April 23, 2024 at 17:04 o'clock