cancel
Showing results for 
Search instead for 
Did you mean: 

Passthru on CIFS

finner
Champ in-the-making
Champ in-the-making
Hi,
I have the following config:

file-servers-custom.xml

   <config evaluator="string-compare" condition="Filesystem Security" replace="true">
      <authenticator type="passthru">
        <Server>my.ldap.server</Server>  <!–   LDAP server –>
      </authenticator>
   </config>



ntlm-authentication-context.xml

    <bean id="authenticationDao" class="org.alfresco.repo.security.authentication.ntlm.NullMutableAuthenticationDao" >
       <property name="nodeService">
          <ref bean="nodeService"/>
       </property>
    </bean>

    <bean id="authenticationComponentImpl" class="org.alfresco.repo.security.authentication.ntlm.NTLMAuthenticationComponentImpl">
        <property name="servers">
            <value>my.ldap.server</value>
        </property>
        <property name="personService">
            <ref bean="personService" />
        </property>
        <property name="nodeService">
            <ref bean="nodeService" />
        </property>
        <property name="guestAccess">
            <value>false</value>
        </property>
    </bean>


ldap-authentication-context.xml

   <bean id="authenticationComponent" class="org.alfresco.repo.security.authentication.ldap.LDAPAuthenticationComponentImpl">
      <property name="LDAPInitialDirContextFactory">
         <ref bean="ldapInitialDirContextFactory"/>
      </property>
      <property name="userNameFormat">
                 <value>uid=%s,ou=Usuarios,dc=audiovisual,dc=es</value>
      </property>
   </bean>

   <bean id="ldapAuthenticationComponentImpl" class="org.alfresco.repo.security.authentication.ldap.LDAPAuthenticationComponentImpl">
      <property name="LDAPInitialDirContextFactory">
         <ref bean="ldapInitialDirContextFactory"/>
      </property>
      <property name="userNameFormat">
         <value>uid=%s,ou=Usuarios,dc=domain,dc=domain</value>
      </property>
   </bean>

    <bean id="ldapInitialDirContextFactory" class="org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl">
        <property name="initialDirContextEnvironment">
             <map>
                <entry key="java.naming.factory.initial">
                    <value>com.sun.jndi.ldap.LdapCtxFactory</value>
                </entry>
                <entry key="java.naming.provider.url">
                    <value>ldap://my.ldap.server:port</value>
                </entry>
                <entry key="java.naming.security.authentication">
                    <value>simple</value>     <!–  DIGEST-MD5 –>
                </entry>
             </map>
        </property>
    </bean>




When I try to map the drive I get a NullPointerException because in PassthruAuthenticator the line


NTLanManAuthContext ntlmCtx = (NTLanManAuthContext) getAuthContext( sess);

doesn't create an ntlmCtx object, it's null and so a few lines further down


type2Msg.buildType2(ntlmFlags, domain, ntlmCtx.getChallenge(), null, tList);

the NullPointer is thrown.
Any ideas what I'm missing in the config ?

Thanks
17 REPLIES 17

daliakamal2005
Champ in-the-making
Champ in-the-making
Hi Finner sorry again if my question wasn't clear:

I did the following:

First I test local Domain as u suggestedSmiley SadNote passuthr authinticator can only work with LDPA or NTLM )

1. I add the ldap-authentication-context.xml
   
<beans> 
    <bean name="authenticationDao" class="org.alfresco.repo.security.authentication.DefaultMutableAuthenticationDao" >
        <property name="allowDeleteUser">
            <value>true</value>
        </property>
    </bean>   
  
   <bean id="authenticationComponent" class="org.alfresco.repo.security.authentication.ldap.LDAPAuthenticationComponentImpl">
      <property name="LDAPInitialDirContextFactory">
         <ref bean="ldapInitialDirContextFactory"/>
      </property>
      <property name="userNameFormat">
         <value>%s</value>         
      </property>
   </bean>

<!–   <bean id="passwordEncoder" class="net.sf.acegisecurity.providers.encoding.Md5PasswordEncoder"></bean>–>

    <bean id="ldapInitialDirContextFactory" class="org.alfresco.repo.security.authentication.ldap.LDAPInitialDirContextFactoryImpl">
        <property name="initialDirContextEnvironment">
             <map>
                <entry key="java.naming.factory.initial">
                    <value>com.sun.jndi.ldap.LdapCtxFactory</value>
                </entry>
                <entry key="java.naming.provider.url">
                    <value>ldap://x.x.x.x:389</value>
                </entry>
                <entry key="java.naming.security.authentication">
                    <value>simple</value>     
                </entry>
             </map>
        </property>
    </bean>
</beans>

2. Modify the file-servers-custom.xml to add the following part:

      
<config evaluator="string-compare" condition="Filesystem Security" replace="true">
       <authenticator type="passthru">
           <LocalDomain/> or <Domain>domainName</Doamin>
      </authenticator>
     </config>
    
In this case i can login from the pc that alfersco installed on it only, and  failed to logon from any another pc even it is on te same Domain.
for the web no problem in the authentication.

Secondly i apply ur solution:
1. Modify the authenticationComponent bean to refer to ur wrapper calss

2. Modify the file-servers-custom.xml to use enterprise authenticator
   
 <config evaluator="string-compare" condition="Filesystem Security" replace="true">
       <authenticator type="enterprise">
      </authenticator>
     </config>
    
In this case no pc in my domain can connect to the CIFS server, even the authintacation work suceffuly on the web

so when trace in the code i find it stop at this line (//HERE) in the EnterpriseCifsAuthenticator Class

   
int i = 0;

       while ( i < clientHash.length && clientHash[i] == localHash[i])
                        i++;
                  
        if ( i != clientHash.length)
           {
                  //  Return a logon failure
                //HERE
                  throw new SMBSrvException( SMBStatus.NTLogonFailure, SMBStatus.DOSAccessDenied, SMBStatus.ErrDos);
                    }
                   
so now can u give any advice to me, plz, i need ur help it is really works with u.

thx a lot

daliakamal2005
Champ in-the-making
Champ in-the-making
Hi Finner

About ur notice that i used the default alfresco calss to authenticationComponent bean this was is the first case.But in the Second case i wrote that I
'Modify the authenticationComponent bean to refer to ur wrapper calss'

As i told u at the runtime the code enter this block
   
if ( i != clientHash.length)
           {
            //  Return a logon failure
           throw new SMBSrvException(SMBStatus.NTLogonFailure,SMBStatus.DOSAccessDenied, SMBStatus.ErrDos);}

and this happen becuase clientHash array its elements not equal the localhash array

so i ask u again shouldn't the getMD4HashedPassword(String userName)method return the hashed password fot this user not the hashed username.

so pls can u give me anyway to communitcate with u online if it works with u.

Finally thx a lot of time as i know that i am taking a lot of it.  Smiley Happy

jimbo762
Champ in-the-making
Champ in-the-making
This is probably a dumb question, but when you say
The class my.package.LDAPAuthenticationComponentWrapper is implemented to use MD4 hashing as follows:
What do you mean?
i understand changing the file to point to the new class, but where do i put the class?
Thanks
Jim

finner
Champ in-the-making
Champ in-the-making
Hi daliakamal2005,
so i ask u again shouldn't the getMD4HashedPassword(String userName)method return the hashed password fot this user not the hashed username.

I agree with you, I would expect to recieve the password in the parameter, hash it and then return the hashed password,  but I'm also receiving the username. Maybe someone else can explain why it's the username..??
I've also had the same exception as you are getting but only in debug and it doesn't happen all the time. That suggests threads to me but I don't have any time to investigate it.
What is your passwordEncoder ? Do you you have something similar to:

authentication-services-context.xml

    <bean id="passwordEncoder" class="org.alfresco.repo.security.authentication.MD4PasswordEncoderImpl"></bean>

Jim,
This is probably a dumb question, but when you say
Quote:
The class my.package.LDAPAuthenticationComponentWrapper is implemented to use MD4 hashing as follows:
What do you mean?
i understand changing the file to point to the new class, but where do i put the class?

I don't understand your question ????
My LDAPAuthenticationComponentWrapper extends the Alfresco class AuthLDAPAuthenticationComponentImpl and I override the getMD4HashedPassword() method. This class goes into a JAR which then goes into the Alfresco.war…………..

Is that what you mean when you ask where does it go ?

jimbo762
Champ in-the-making
Champ in-the-making
Yes, that is what i do not know about.  How does one accomplish this:
This class goes into a JAR which then goes into the Alfresco.war

Yes, i'm new to this class and war thing 🙂
Thanks
Jim

kevinr
Star Contributor
Star Contributor
The file format of both WAR and JAR is a simple ZIP file. You can use any ZIP application such as WinZIP or WinRAR or whatever to unpack it. You can then modify the files on your file system and use the ZIP application to repack up the JAR/WAR.

Thanks,

Kevin

davidw
Champ in-the-making
Champ in-the-making
What imports should be used when compiling the class-file?

Would it be possible to provide a step by step guide for creating the jar file, or post the jar file somewhere for us that are not used to working with java?

Thanks,
David

kevinr
Star Contributor
Star Contributor
You'll need to download the SDK to build the JAR files - it includes all 3rd party JARs and ANT build scripts.

If someone has compiled the JAR we can host it somewhere if they make it available.

Thanks,

Kevin