new Posted February 14, 2013 Share Posted February 14, 2013 hi, is possible use active directory authentication in iis? Link to comment Share on other sites More sharing options...
Marlon Nardi Posted February 15, 2013 Share 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 Link to comment Share on other sites More sharing options...
new Posted February 15, 2013 Author Share Posted February 15, 2013 Please give me an example Link to comment Share on other sites More sharing options...
Marlon Nardi Posted February 15, 2013 Share 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 Link to comment Share on other sites More sharing options...
new Posted February 18, 2013 Author Share Posted February 18, 2013 thank you very much .. Link to comment Share on other sites More sharing options...
bruno-pere Posted February 22, 2013 Share Posted February 22, 2013 Very nice! Muito bom! Bruno Link to comment Share on other sites More sharing options...
wandobh Posted July 28, 2015 Share 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/ Link to comment Share on other sites More sharing options...
Bresler Posted July 30, 2015 Share 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 Link to comment Share on other sites More sharing options...
rencarnacion Posted July 30, 2015 Share Posted July 30, 2015 Are you running your application standalone or using IIS ? Link to comment Share on other sites More sharing options...
Bresler Posted July 30, 2015 Share Posted July 30, 2015 As ISAPI App on IIS 7, but I think this solution can work on an standalone app too... Link to comment Share on other sites More sharing options...
Marlon Nardi Posted July 30, 2015 Share 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. Link to comment Share on other sites More sharing options...
Bresler Posted July 31, 2015 Share Posted July 31, 2015 A little detail, you must update JEDI.INC and KYLIX.INC with the last version on JEDI Library. Regards Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now