new Posted February 14, 2013 Posted February 14, 2013 hi, is possible use active directory authentication in iis? Quote
Marlon Nardi Posted February 15, 2013 Posted February 15, 2013 I use Active Directory in my applications without UniGui nennhum problem.IIS has no connection with the AD!Att, Marlon Nardi Quote
Marlon Nardi Posted February 15, 2013 Posted February 15, 2013 unit U_Funcao_valida_senha; interface uses Forms, SysUtils, Dialogs, ADODB, ActiveX; function validasenha(usuario, senha: string): Boolean; implementation uses SqlExpr, MainModule; function validasenha(usuario, senha: string): Boolean; var SQLQuery : TSQLQuery; ADOConnection : TADOConnection; ADOQuery : TADOQuery; begin {Conexão Active Directory} if Trim(SQLQuery.Fields[0].AsString) = 'AUTENTICAÇÃO ACTIVE DIRECTORY' then begin try try CoInitialize(nil); ADOConnection := TADOConnection.Create(Application); ADOConnection.ConnectionString:= 'Provider=ADSDSOObject;User Id='+usuario+'@domain.com.br;Password='+senha+';'; ADOConnection.Mode := cmRead; ADOConnection.Provider := 'ADsDSOObject'; ADOConnection.LoginPrompt := False; ADOConnection.Connected := True; ADOQuery := TADOQuery.Create(Application); ADOQuery.Connection := ADOConnection; ADOQuery.CursorType := ctStatic; ADOQuery.SQL.Clear; ADOQuery.Close; ADOQuery.SQL.Add('SELECT SamAccountName, Name, loginlogix '+ ' FROM ''LDAP:/domain.com.br'' '+ ' WHERE objectClass= ''user'' '+ ' AND SamAccountName = '''+usuario+''' '); ADOQuery.Open; if ADOQuery.FieldByName('loginlogix').AsString = EmptyStr then begin ShowMessage('Usuário '+usuario+' Não Possui Usuario do Logix Cadastrado no Active Directory '+#13+ 'Favor Contatar o Administrador de Sistemas.'); Result := False; Exit; end else begin ID.glo_usuario := Trim(ADOQuery.FieldByName('loginlogix').AsString); Result := True; Exit; end; except Result := False; end; finally CoUninitialize; FreeAndNil(ADOConnection); FreeAndNil(ADOQuery); end; end; finally FreeAndNil(SQLQuery); end; end; end; 1 Quote
wandobh Posted July 28, 2015 Posted July 28, 2015 Marlon bom dia. Poderia me dizer o que estou fazendo de errado? http://forums.unigui.com/index.php?/topic/5587-error-login-form/ Quote
Bresler Posted July 30, 2015 Posted July 30, 2015 Hi guys I'm using LDAP authentication too. Firstly I was using LDAPAdmin but it seems this project was abandoned and doesn't work for 64 bits. So I decided to find other solution which was Ararat Synapse and works perfect in 64 bits, very light and easy to use. Here is an example: function TUniLoginForm1.LDAPAuth(AUsername, APassword: String): Boolean; var LLdap: TLDAPsend; begin Result := false; LLdap := TLDAPsend.Create; try LLdap.TargetHost := 'ldap_server_name_or_ip'; if not AUsuario.ToLower.StartsWith('domainname') then AUsuario := Format('domainname\%s', [AUsername.ToLower]); LLdap.UserName := AUsername; LLdap.Password := APassword; LLdap.Login; Result := LLdap.Bind; finally LLdap.Free; end; end; The official LDAP sample is here Quote
rencarnacion Posted July 30, 2015 Posted July 30, 2015 Are you running your application standalone or using IIS ? Quote
Bresler Posted July 30, 2015 Posted July 30, 2015 As ISAPI App on IIS 7, but I think this solution can work on an standalone app too... Quote
Marlon Nardi Posted July 30, 2015 Posted July 30, 2015 Hi guys I'm using LDAP authentication too. Firstly I was using LDAPAdmin but it seems this project was abandoned and doesn't work for 64 bits. So I decided to find other solution which was Ararat Synapse and works perfect in 64 bits, very light and easy to use. Here is an example: function TUniLoginForm1.LDAPAuth(AUsername, APassword: String): Boolean; var LLdap: TLDAPsend; begin Result := false; LLdap := TLDAPsend.Create; try LLdap.TargetHost := 'ldap_server_name_or_ip'; if not AUsuario.ToLower.StartsWith('domainname') then AUsuario := Format('domainname\%s', [AUsername.ToLower]); LLdap.UserName := AUsername; LLdap.Password := APassword; LLdap.Login; Result := LLdap.Bind; finally LLdap.Free; end; end; The official LDAP sample is here Thanks for sharing. the project Ararat Synapse has features that I needed. Quote
Bresler Posted July 31, 2015 Posted July 31, 2015 A little detail, you must update JEDI.INC and KYLIX.INC with the last version on JEDI Library. Regards Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.