Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

mows

Propriedades Active Directory. Como trazer?!

Recommended Posts

Boa tarde pessoal.

Estou com uma dúvida ao retornar os dados de usuário do Active Directory.

No código abaixo faço conexão com o AD e verifico o nome de usuário e senha.

A verificação está funcionando, porém eu gostaria de retornar na tela alguns dados do usuário, tal como o nome completo e último login.

As propriedades FullName e LastLogin eu achei em outro fórum, não sei se está correto, até porque não aparece nada na tela onde faço response dessas duas propriedades, nem erro.

 

Se alguem puder me ajudar... Agradeço.

 

[]s

 

CODE
If Request.Form("strUsername") <> "" Then

Dim strADsPath

strADsPath = "WinNT://ad.local"

 

'userid =

strUserName = "ad.local\" & Request.Form("strUserName")

strPassword = Request.Form("strPassword")

 

if (not strADsPath= "") then

 

' bind to the ADSI object and authenticate Username and password

Dim oADsObject

Set oADsObject = GetObject(strADsPath)

 

response.write "Authenticating...<br><br>"

 

Dim strADsNamespace

Dim oADsNamespace

strADsNamespace = left(strADsPath, instr(strADsPath, ":"))

set oADsNamespace = GetObject(strADsNamespace)

 

On error resume next

 

Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, strUserName,strPassword, 0)

 

 

 

if not (Err.number = 0) then

Response.Write "<font color='red'><font size = 5><u><b>Authentication has failed...<b></u></font></font>"

else

With Response

Response.write "USER AUHTENTICATED!<BR>"

Response.Write(" "&strUsername&" ")

Response.Write ("AccountExpirationDate: " & strUsername.FullName & "")

Response.write ("LastLogin: " & strUsername.LastLogin & "")

end with

end if

 

end if

End If

Compartilhar este post


Link para o post
Compartilhar em outros sites

Veja lhe ajuda em algo:

<%
Dim UserID, wUserName, wDominio, wUser, oUser
UserID = ""

If IsEmpty(UserID) Or IsNull(UserID) Or UserID = "" Then
UserID = Request.ServerVariables("LOGON_USER")
UserID = LCase(UserID)

If IsEmpty(UserID) Or IsNull(UserID) Or UserID = "" Then
Response.Status = "401 Acesso Negado"
Response.Write ("Negado. Você não está autorizado a este site.")
Response.End
Else
UserID = Replace(UserID, "\", "/")
If InStr(UserID, "/") < 1 Then
UserID = "defaultdomain/" & UserID
End If
End If

End If

GetName = ""
wUserName = "Usuário não cadastrado"

mudar = Split(UserID, "/")

wDominio = mudar(0)
wUser = mudar(1)

Set oUser = GetObject("WinNT://" & wDominio & "/" & wUser)
wUserName = oUser.FullName
If err.Number <> 0 Then
err.Clear
wUserName = "erro - Usuário não cadastrado"
End If
Session("Nome") = wUserName
Session("Login") = UCase(wUser)
Session("Dominio") = UCase(wDominio)

response.write Session("Nome") & "<br>"
response.write Session("Login") & "<br>"
response.write Session("Dominio") & "<br>"
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.