Index: C:/Projekte/itonics/trendradar/sites/all/modules/contrib/ldap/ldap_profile/ldap_profile.module
===================================================================
--- C:/Projekte/itonics/trendradar/sites/all/modules/contrib/ldap/ldap_profile/ldap_profile.module	(revision 8369)
+++ C:/Projekte/itonics/trendradar/sites/all/modules/contrib/ldap/ldap_profile/ldap_profile.module	(revision 8383)
@@ -70,6 +70,23 @@
   return $info;
 }
 
+function _ldap_profile_iscustom($field)
+{
+    $is_custom_field = field_info_field($field) != null || strpos($field, "field_") !== FALSE;
+        
+    $is_custom_field = strpos($field, "field_") !== FALSE;
+     $fieldinfo =  field_info_field($field);
+     if($fieldinfo)
+     {
+         if(array_key_exists('user', $fieldinfo['bundles']))
+         {
+             $is_custom_field = true;
+         } 
+     }
+        
+    return $is_custom_field;
+}
+
 /**
  * Implements hook_user_login().
  */
@@ -103,7 +120,7 @@
   if (!$authuser || !$ldapuser || $dn == "") {
     return;
   }
-
+  $customfields = array();
   $ldapfields = array();
   $dnLookups = array();
   $mapping = ldap_profile_get_mapping();
@@ -112,7 +129,13 @@
   // Put all our mappings into the ldapfields array
   if ($mapping != NULL) {
     foreach (array_keys($mapping) as $field) {
-      if (strpos($field, "field_") !== FALSE) {
+       
+        $is_custom_field = _ldap_profile_iscustom($field);
+        if($is_custom_field)
+            $customfields[$field] = $is_custom_field;
+      
+      
+      if ($is_custom_field) {
         //We have a custom field
         if (strpos($mapping[$field], "[") !== FALSE) {
           $token_keys = ldap_server_tokens_needed_for_template($mapping[$field]);
@@ -153,11 +176,16 @@
       $dnLdapdata[$curDnLookup] = $curDnLookupResult[0];
     }
   }
+  
+  
 
   // Set/Update profile field information
   if (is_array($mapping)) {
     foreach (array_keys($mapping) as $field) {
-      if (strpos($field, "field_") !== FALSE) {
+        
+        
+        
+      if (array_key_exists($field, $customfields)) {
         $add = FALSE;
         $toAdd = '';
         $ldapEntry = ($derivedMapping[$field]['derive']) ? $dnLdapdata[$derivedMapping[$field]['derive_value']] : $ldapdata;
@@ -200,24 +228,39 @@
  **/
 function ldap_profile_form_user_profile_form_alter(&$form, $form_state) {
 
-  $not_changeable = t('This username is automatically set and may not be changed.');
+  $not_changeable = 'This field is automatically set and may not be changed.';
   global $user;
-  if ($user->uid > 1 && is_array($form_state['user']->data) && isset($form_state['user']->data['ldap_authentication'])) {
+  if (is_array($form_state['user']->data) && isset($form_state['user']->data['ldap_authentication'])) {
     $mapping = ldap_profile_get_mapping();
     if ($mapping != NULL) {
       foreach (array_keys($mapping) as $field) {
-        if (strpos($field, "field_") !== FALSE) {
+          
+        $is_custom_field = _ldap_profile_iscustom($field);
+          
+        if ($is_custom_field) {
           if (array_key_exists($field, $form)) {
-            $form[$field]['#disabled'] = TRUE;
+              
+            if($user->uid > 1) 
+                $form[$field]['#disabled'] = TRUE;
+            
             $form[$field]['#description'] = $not_changeable;
             if (isset($form[$field]['und'][0])) {
-              $form[$field]['und'][0]['#description'] = $not_changeable;
+              if (isset($form[$field]['und'][0]['value'])) {
+                  $form[$field]['und'][0]['value']['#description'] = $not_changeable;
+              }
+              else
+              {
+                    $form[$field]['und']['#description'] = $not_changeable;
+                    $form[$field]['und'][0]['#description'] = $not_changeable;
+              }
             }
           }
         }
       }
     }
-    $form['account']['name']['#disabled'] = TRUE;
+    if($user->uid > 1) 
+        $form['account']['name']['#disabled'] = TRUE;
+    
     $form['account']['name']['#description'] = $not_changeable;
   }
   if ($user->uid < 2) {
